如何绑定DropDownList的是里面中继器? [英] how to bind dropdownlist which is inside repeater?
本文介绍了如何绑定DropDownList的是里面中继器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要绑定的DropDownList这是一个repeater.my code里面的
< ASP:直放站ID =rep_UnAssignComps=服务器>
<&ItemTemplate中GT;< ASP:DropDownList的ID =drp_CompPropAddress=服务器>
< / ASP:DropDownList的>< / ItemTemplate中>< / ASP:直放站>
解决方案
在您的Repeater的的ItemDataBound
事件中使用下列内容:
如果(e.Item.ItemType == || ListItemType.Item
e.Item.ItemType == ListItemType.AlternatingItem)
{ ((DropDownList的)e.Item.FindControl(drp_CompPropAddress))数据源=(DataRowView的)e.Item.DataItem; //或任何其它数据源。
((DropDownList的)e.Item.FindControl(drp_CompPropAddress))的DataBind();}
I want to bind dropdownlist which is inside a repeater.my code is
<asp:Repeater ID="rep_UnAssignComps" runat="server">
<ItemTemplate><asp:DropDownList ID="drp_CompPropAddress" runat="server">
</asp:DropDownList></itemTemplate></asp:Repeater>
解决方案
On your Repeater's ItemDatabound
event use the following:
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
((DropDownList)e.Item.FindControl("drp_CompPropAddress")).DataSource =(DataRowView) e.Item.DataItem;//Or any other datasource.
((DropDownList)e.Item.FindControl("drp_CompPropAddress")).DataBind();
}
这篇关于如何绑定DropDownList的是里面中继器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文