Wrox Programmer Forums
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 19th, 2006, 12:52 PM
Authorized User
Join Date: Nov 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yasminnnnn
Default preselecting dropdownlist item

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..

Old December 26th, 2006, 06:52 AM
Authorized User
Join Date: Dec 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sunnys Send a message via Yahoo to Sunnys

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting DropDownList Item yes_no ASP.NET 1.0 and 1.1 Professional 1 April 8th, 2008 08:00 AM
adding dropdownlist item to a textbox alto ASP.NET 2.0 Basics 2 May 24th, 2007 01:14 AM
How to set selected item in Dropdownlist? MTLedari ASP.NET 2.0 Basics 4 December 27th, 2006 12:53 AM
Want Combo Box first item if only 1 item markw707 Access 3 June 9th, 2004 04:03 PM
Find Out First Item of each item Group Jane SQL Language 1 November 22nd, 2003 12:42 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.