问题描述
我有一个中继器和和,我设置其的DataSourceID
。
< ASP:直放站ID =rpProducts=服务器的DataSourceID =ItemDataSource>
<&HeaderTemplate中GT; ....< / HeaderTemplate中>
<&ItemTemplate中GT;
....
< / ItemTemplate中>
< FooterTemplate>
< / FooterTemplate>
< / ASP:直放站>
但我一段时间,我想改变的DataSourceID
和加载数据,然后重新设置 ItemDataSource
。
这是我的code变革的rpProducts 的DataSourceID
。
rpProducts.DataSourceID = NULL;
rpProducts.DataSource =货物;
rpProducts.DataBind();
于是,我再次想设置的的DataSourceID
到 ItemDataSource
。
我该怎么办呢?
我尝试这样。但不工作
rpProducts.DataSourceID = NULL;
rpProducts.DataSourceID = ItemDataSource.ToString();
你可以尝试用:ItemDataSource.ID
另外,两个数据源和DataSourceID的,不能在同一时间设置,所以你必须设置数据源为null。
rpProducts.DataSource = NULL;
rpProducts.DataSourceID = ItemDataSource.ID;
rpProducts.DataBind();
I have a repeater and and and I set its DataSourceID
.
<asp:Repeater ID="rpProducts" runat="server" DataSourceID="ItemDataSource" >
<HeaderTemplate>....</HeaderTemplate>
<ItemTemplate>
....
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
But I some time I want to change the DataSourceID
and load data and again set the ItemDataSource
.
This is my code for change the rpProducts DataSourceID
.
rpProducts.DataSourceID = null;
rpProducts.DataSource = goods;
rpProducts.DataBind();
So then again I want to set the DataSourceID
to ItemDataSource
.
How can I do it?
I try like this. but is not working
rpProducts.DataSourceID = null;
rpProducts.DataSourceID = ItemDataSource.ToString();
Can you try with: ItemDataSource.ID
Also, both datasource and datasourceid cannot be set at same time, so you will have to set the datasource to null.
rpProducts.DataSource = null;
rpProducts.DataSourceID = ItemDataSource.ID;
rpProducts.DataBind();
这篇关于如何更改中继器的DataSourceID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!