solve the problem

Aug 11 2010 2:16 PM

I have three tables course,faculty,student.I have implemented one to many relation between tables using primary key constraint & foreign key constraint.my design consists of one dropdownlist & two datagridviews.I bind the common column of course table to dropdownlist.when i select the combobox item it will display corresponding faculty table records in one gridview & student table records in another gridview.these are in form load only.I get the result in C# Windows forms.but i am not getting same result in ASP.net. it is binding
courseid to dropdownlist & faculty table to  gridview1,student table to gridview2.problem is when I select the dropdownlist item the corresponding table data does not displayed in corresponding gridviews.but I get the result in C# winforms with same bellow code(dropdownlist==combobox).if any body knows please give solution clearly.
I set the dropdownlist property autopostback is true  .


private void Form1_Load(object sender, EventArgs e)
{
string cs = "uid=sa;pwd=nanda;database=satyadatabase";
SqlConnection conn = new SqlConnection(cs);
// conn.Open();
SqlCommand cmd1 = new SqlCommand("select * from course", conn);
SqlCommand cmd2 = new SqlCommand("select * from faculty", conn);
SqlCommand cmd3 = new SqlCommand("select * from student", conn);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
SqlDataAdapter da2 = new SqlDataAdapter(cmd2);

SqlDataAdapter da3 = new SqlDataAdapter(cmd3);
DataSet ds = new DataSet();
da1.Fill(ds, "coursenew");
da2.Fill(ds, "facultynew");
da3.Fill(ds, "studentnew");
ds.Relations.Add("coursefac", ds.Tables["coursenew"].Columns["courseid"], ds.Tables["facultynew"].Columns["courseid"]);
ds.Relations.Add("coursest", ds.Tables["coursenew"].Columns["courseid"], ds.Tables["studentnew"].Columns["courseid"]);
Dropdownlist1.DataSource = ds.Tables["coursenew"];
Dropdownlist1.DataValueField = "courseid";
gridfaculty.DataSource = ds.Tables["coursenew"];
gridfaculty.DataMember = "coursefac";
gridstudent.DataSource = ds.Tables["coursenew"];
gridstudent.DataMember = "coursest";

}


Answers (1)