Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
|
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 October 24th, 2006, 12:53 AM
Authorized User
 
Join Date: Sep 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default DropDownList-SelectedIndexChange(Plz Help)

i hav' a drpdwnlst and a textbox on my page. there is a table in sql server 2000 tat contains 2 columns, they are an ID column and a NAME column(the ID column is the Primary Key). the drpdwnlst displays the data from the NAME column using SqlDataSource1. the querystring in sqldatasource1 is the select query for the NAME column.
Now wat i want is, when a particular NAME is selected from the drpdwnlst then the ID for tat particular NAME should be dislayed in the textbox control. Can anyone plz share ur knowledge if u know how to achieve this ???

THANX in ADVANCE



__________________
--------------------------------------------------
therez nothin\' as impossible, bcaz the word itself says : \'i\'-\'m\'-\'possible\'
 
Old October 26th, 2006, 11:09 AM
Registered User
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

in the SelectedIndexChanged event of your dropdownlist, set the text of your textbox to dropdownlist.SelectedValue

 
Old October 27th, 2006, 01:34 AM
Authorized User
 
Join Date: Nov 2005
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In select Query from datasource select ID and Name..from TABLENAME
Set Dropdown Value Field as ID and Text Field as Name..
so when Name is selected
Then set textbox value to dropdown selected.value...

HTH,
Vivek
 
Old October 27th, 2006, 08:13 AM
Authorized User
 
Join Date: Sep 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 well, i've got it!!!
select both NAME and ID columns in SqlDataSource1,
then set the DataTextField property to the NAME column,
and DataValueField property to ID column.
After that in SelectedIndexChanged Event set the textbox1.text=dropdownlist1.selectedvalue.
also u have to enable the postback of dropdownlist to TRUE

Thanx a lot guyz





Similar Threads
Thread Thread Starter Forum Replies Last Post
plz.....plz solve out my problem.... kethireddy435 ASP.NET 1.x and 2.0 Application Design 1 October 4th, 2007 12:56 PM
DropDownList-SelectedIndexChange(Plz Help) dagad ASP.NET 2.0 Basics 8 November 6th, 2006 01:40 AM
Plz help me ritesh_ch23 Pro JSP 1 July 18th, 2006 10:46 PM
plz help me kale_tushar C++ Programming 1 February 26th, 2004 01:01 PM
SelectedIndexChange uses ListItem value Randy76 VS.NET 2002/2003 3 September 11th, 2003 09:33 AM





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