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)


 
 
 
Please add 4 and 1 and type the answer here:
 

Live Comment Preview:

 
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910