Click here to Skip to main content
16,018,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 combobox & two datagridviews.I bind the common column of course table to combobox.when i select the combobox item it will display corresponding faculty table records in one gridvie & student table records in another gridview.these are in form load only.I get the result in C# Windows forms.given the code billow.but i am not getting same result in ASP.net.For this give asp.net full code.please use relations concept.

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 da2 = new SqlDataAdapter(cmd);
SqlDataAdapter da1 = new SqlDataAdapter(cmd4);
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"]);
comboucname.DataSource = ds.Tables["coursenew"];
comboucname.DisplayMember = "coursename";
gridfaculty.DataSource = ds.Tables["coursenew"];
gridfaculty.DataMember = "coursefac";
gridstudent.DataSource = ds.Tables["coursenew"];
gridstudent.DataMember = "coursest";
}

[edit]Tags only - OriginalGriff[/edit]
Posted
Updated 11-Aug-10 8:14am
v2

Why would you expect me to do your homework for you? If you have a specific problem, please ask about it. "Gimme codez" is the best way to alienate anybody here...
 
Share this answer
 
Adding to what OriginalGriff said -
Here is what is expected by enquirers:
1. TRY first what you want to do!
2. Formulate what was done by you that looks like an issue/not working.

Try them and tell if you face issues.
Members will be more than happy to help like this.

Looks like you have a Winforms working code as you say and yet you are unable to get things working in Webforms? Where do you think the difference happens in both?
 
Share this answer
 

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