现在默认绑定的是XML1的数据,然后下面有个按钮我想点击它然后ListView绑定到XML2的数据。却出现了“RadListView1”上同时定义了 DataSource 和 DataSourceID。请移除一个定义。 的问题
代码如下
<telerik:RadListView ID="RadListView1" runat="server"
DataSourceID="XmlDataSource1">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF" width="80px">
<%# Eval("题序")%>
</td>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<a href="WrongAnswer_QuestionDetail.aspx"><%# Eval("题目")%></a>
</td>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<%# Eval("我的答案")%>
</td>
<td align="center" valign="middle" bgcolor="#FFFFFF">
<%# Eval("正确答案")%>
</td>
</tr>
</ItemTemplate>
</telerik:RadListView>
后台代码如下:
protected void btnAll_Click(object sender, ImageClickEventArgs e)
{
btnAll.Visible = false;
RadListView1.DataSource = null;
RadListView1.DataSource=XmlDataSource2;
btnWrong.Visible = true;
}
protected void btnWrong_Click(object sender, ImageClickEventArgs e)
{
btnAll.Visible = true;
RadListView1.DataSource = null;
RadListView1.DataSource = XmlDataSource1;
btnWrong.Visible = false;
}
------解决方案--------------------------------------------------------
改成如下试试
this.RadListView1.DataSourceID = null;
this.RadListView1.DataSource = XmlDataSource1;