1
<asp:DropDownList>
上的方法是否與Repeater上的OnItemDataBound等效?ASP.NET DropDownList OnItemDataBound
原因是我想檢查每個值,然後將其放入下拉列表中。
<asp:DropDownList>
上的方法是否與Repeater上的OnItemDataBound等效?ASP.NET DropDownList OnItemDataBound
原因是我想檢查每個值,然後將其放入下拉列表中。
與OnItemDataBound沒有任何相似之處,它會給你一個項目上下文。有一些像OnDataBound這樣的事件會在綁定時觸發。
你問這個事件的原因是爲了豐富行而不是過濾,即使這個事件也不會幫助你。
最好的辦法來解決你的問題
的原因是我希望把它在下拉 下拉列表之前檢查每個值。
是做一些事情,如下面的僞代碼
this.YourDropDownList.Items.Clear();
var lst = new List<ListItem>();
var yourCollection= <YOURCollection after Apply Linq Conditions check>
foreach (var obj in yourCollection)
{ //loop and add
this.YourDropDownList.Items.Add(new ListItem {Text = obj.Prop1, Value = obj.prop2});
}
你能不能把在下拉列表之前檢查值? –
我會逐個手動插入它們 – hardkoded