Select DropDownList item after declarative DataBinding

Select DropDownList item after declarative DataBinding

The declarative controls of ASP.NET are really great. However, there are some times, when it may not seem so.
Let’s say you have a DropDownList which is bound by a DataSource control.

Also, you have other pages hitting this page, with querystrings, and based on the item in the querystring, you’d like the to select that item.
In ASP.NET, you’d just code it, and select it after the code, or in the Pre-render event.

DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByText(Request.Querystring("YourQuerystring"));

Share this post

Comment (1)

  • Jeanna Kandace Reply

    you are truly a good webmaster. The web site loading pace is amazing. It kind of feels that you’re doing any unique trick. Furthermore, The contents are masterwork. you have performed a wonderful activity on this matter!

    January 13, 2022 at 6:52 AM

Leave a Reply

Your email address will not be published. Required fields are marked *