how to link combo box with text boxes

Asked By Priyanka
02-Sep-10 01:48 PM
Earn up to 0 extra points for answering this tough question.

suppose i have one combo box and two text boxes which are linked with access database and i want that whenever user selct student id from combo box then the name of the student and age should be filled in text boxes...
plz give me some simple example with code,\\.....

  re: how to link combo box with text boxes

Reena Jain replied to Priyanka
03-Sep-10 02:58 AM
Hi,

use the following code

protected void Combobox1_SelectedIndexChanged(object sender, EventArgs e)
    {
//to send the your combox id in database to fatch name and other detail

 SqlCommand cmdd = new SqlCommand("Select * table where studentid='" + Combobox1.selectedvalue + "'", LiveCon);
                          SqlDataAdapter adpp = new SqlDataAdapter(cmdd);
                          DataTable dtr = new DataTable();
                          adpp.Fill(dtr);
                          if (dtr.Rows.Count > 0)
                          {
                           textbox1.Text=dt.rows[0]["Name"].tostring();
                          }
}

hope this will help
Create New Account