ListItemCollection.AddRange sets selection to the first item

I have a custom DropDownList derived from System.Web.UI.WebControls.DropDownList.
And I've noticed that after populating data using
ListItemCollection.AddRange Method,
the DropDownList.SelectedIndex Property becomes set to 0 from -1.

I consider this as an unexpected behavior and have to change it back to -1- unselected.

            Items.Clear();

            Debug.Assert(SelectedIndex == -1);

            Items.AddRange(cachedItems);

            Debug.Assert(SelectedIndex == 0);//is it correct?

posted @ Wednesday, August 15, 2007 3:39 PM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345