p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   preselecting dropdownlist item (http://p2p.wrox.com/showthread.php?t=51749)

yasminnnnn December 19th, 2006 12:52 PM

preselecting dropdownlist item
 
hey
i have a detailsview and a seperate dropdownlist in my page. i get a variable MTDescription via querystring from another page. i try to find that text value in the dropdownlist items and i want it to be returned as selected item.dropdownlist gets its values from a sql datasource..
this is what i tried:
            Label11.Text = Request.QueryString["MTDescription"];
            DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.Fi ndByText(Label11.Text));


when i write it to button_click event, it works fine however i want it to happen when the page loads or something else than clicking a button..i tried many events but they dont work:(

what can i do?
many thanks..


Sunnys December 26th, 2006 06:52 AM

hi,
u can directly write this code on pageload use this
DropDownList1.Items.FindByText(Label11.Text).selec ted=true;
it will help



All times are GMT -4. The time now is 10:08 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.