Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Updated 15-Mar-11 1:07am
v2

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.
 
Share this answer
 
v2
1.get value of dropdown on selected index changed event
C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  {
      int intReference = int.Parse(ddlCompany.SelectedValue.ToString());
// call the function where u will interact with database .
      fnShowDetails(intReference);
  }

2. // here u should call database and bind grid with data table .
C#
protected void fnShowDetails(int intReference)
  {
      DataSet dsGetTechAcq = new DataSet();
      dsGetTechAcq = objExpenditure.fnGetTechAcq(intReference);
      gvHardware.DataSource = dsGetTechAcq.Tables[0];
      gvHardware.DataBind();
}
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900