473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Drop Down List help please

16
Hello

I have a drop down list that retrieves data from a data base.
Under that I have a textbox that I want to retrieve information also from the database depending on the previously selected item.

For example, if i select "Computer" from the dropdown list, the textbox should display "PC".

This is part of my graduation project and I really need help.
Thanks :)
Mar 13 '07 #1
2 1073
public static void LoadCombo(DropDownList cmb,string KeyCodeColumn,string KeyNameColumn,string TableName,DataSet ds)
{
cmb.Items.Clear();
foreach (DataRow dr in ds.Tables[TableName].Rows)
{
ListItem ls = new ListItem(dr[KeyNameColumn].ToString().Trim());
if (KeyCodeColumn != "")
ls.Value = dr[KeyCodeColumn].ToString().Trim();
cmb.Items.Add(ls);
}
}

Now, if you want to display the value of the selected item in the textbox1, you can show it using
textbox1.text = cmb.SelectedValue;
Mar 13 '07 #2
nmsreddi
366 256MB
Hello

If your data is limited and static then you can go for arraylist colletion other if

you want the data to get from database then simply you can use auto postback

property of the combobox and write the code in combo selected index changed

event for each time bind that corresponding data to the textbox its not a problem


Good luck
Mar 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dec | last post by:
Ok to simplify things I'll just give an example. This is pretty much what I want to do (minus the postcode): http://www.perrys.co.uk/usedcar?ID=F5J9BNNBMVK00DF I have relatively little...
2
by: R-D-C | last post by:
Hi, got a drop-down list on a windows form in VS.NET2003. In the form load when NOT a postback, we add four values to the drop-down list. These appear in Internet Explorer. When you click...
3
by: Don Wash | last post by:
Hi There! I have a Server-side Drop-down box in ASP.NET (VB) page. What do I do to widen the Drop down box's Pull-Down list's width? I'm not talking about the Drop-down box's width but the box...
2
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
4
by: Laura K | last post by:
I have a drop down menu which has a list of subcategories and the initial value is "please choose a Subcategory". When the user chooses a subcategory they are taken to a new page where the drop...
8
by: Ed Dror | last post by:
Hi there ASP.NET 2.0 VB & SQL Express Lest take Northwind Categories Products as example I create a table that hold these two together and I create a stored procedure like select ProductID,...
3
by: Brad Isaacs | last post by:
ASP.NET 2.0 / SQL Server 2000 db / Visual Basic Code behind On my .aspx page I have added an SQL Datasource that contains the SQL query to retrieve the list for my Drop Down List Box. Using...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
8
by: dskanth | last post by:
I have 4 drop down lists, namely Location, country, State and City. Ex: Location: Asia, Country: India, State: Andhra Pradesh, City: Hyderabad. If i select any option in the Location drop down...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.