SIVA

SIVA

  • NA
  • 742
  • 706.5k

How to fetch child records from DataRelation class

Dec 23 2011 5:09 AM
Hi All,
i have established the connection between two tables using
DataRelation class as follows. & i have two gridviews
for parent table primary key column in Gridview i have link button.
now my requirement is
when i click the DNo in parent gridview by using DataRelation it have to fetch the child records & i have to display those records in another gridview


oCon=new SqlConnection(ConfigurationManager.AppSettings["conStr"]);
oDADept =new SqlDataAdapter("select * from tbl_Department order by DNo",oCon);
oDAEmp =new SqlDataAdapter("select * from tbl_EmpDept order by ENo", oCon);
oDS =new DataSet();
oDADept.Fill(oDS,"tbl_Department");
oDAEmp.Fill(oDS,"tbl_EmpDept");
oDR = new DataRelation("DeptEmp", oDS.Tables["tbl_Department"].Columns["DNo"], oDS.Tables["tbl_EmpDept"].Columns["DNo"]);
oDS.Relations.Add(oDR);



Answers (2)