Click here to Skip to main content
Rate this: bad
good
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
v2
Rate this: bad
good
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.
  Permalink  
v2
Rate this: bad
good
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 .
      fnShowDetails(intReference);
  }
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];
      gvHardware.DataBind();
}
  Permalink  
v2

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



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