Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

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 on Wednesday, August 15, 2007 3:39 PM ASP.NET | Back to top


Comments on this post: ListItemCollection.AddRange sets selection to the first item

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net