selectedIndex is lost during postbacks - ASP.NET

后端 未结 9 1788
北海茫月
北海茫月 2021-01-13 06:35

I have a list box control:




The code behind resembles:

<         


        
9条回答
  •  星月不相逢
    2021-01-13 07:19

    Databinding DropDownLists/ListBoxes is painful, because they often bind to the wrong values.

    I've given up on using DataBind(), and just resort to using a Foreach loop:

    foreach (Item i in DataSet)
    {
         listBox.Items.Add(etc);
    }
    

提交回复
热议问题