Click here to Skip to main content
11,583,865 members (64,533 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: SQL-server-2005
Actually I want to bind a single field from one table into DropDownList. I need to display the remaining fields or the records which are related to the field I selected from the DropDownList will be shown in DataGrid. How can I implement these things? I am using SQL Server 2005 and Visual Studio 2003. Can any one help me?

[edit]Spurious bold removed, capitalization, words not found in dictionary converted to proper English.[/edit]
Posted 15-Mar-11 1:01am
Edited 15-Mar-11 1:07am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

1)Get the values(column) from db and bind them to dropdownlist using a dataset.
populating the dropdownlist[^]
2)In Dropdown selected Index changed event using the id(selected index)/selecteditem text hit the db get the values for that selected text.
3)Bind the DataGrid with the values you get from db.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

1.get value of dropdown on selected index changed event
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
      int intReference = int.Parse(ddlCompany.SelectedValue.ToString());
// call the function where u will interact with database .
2. // here u should call database and bind grid with data table .
protected void fnShowDetails(int intReference)
      DataSet dsGetTechAcq = new DataSet();
      dsGetTechAcq = objExpenditure.fnGetTechAcq(intReference);
      gvHardware.DataSource = dsGetTechAcq.Tables[0];

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 480
1 Sergey Alexandrovich Kryukov 285
2 virusstorm 268
3 Dave Kreskowiak 230
4 Richard Deeming 220
0 OriginalGriff 1,523
1 Sergey Alexandrovich Kryukov 995
2 Abhinav S 696
3 Dave Kreskowiak 621
4 Suvendu Shekhar Giri 568

Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100