SIVA

SIVA

  • NA
  • 742
  • 708.5k

How to display the records from the DataRelation class

Dec 22 2011 9:31 AM

Hi All,
i have two tables namely tbl_Department Dno(PK) --Parent
 tbl_EmpDept Dno(FK) --child

I have stored both tables in DataSet
nd i have two DataTables namely oDTDept & oDTEmp
i have established the connection between the two tables by using
 DataRelation class.

i have one gridview & its bound with tbl_Department table
nd in that DNo is link button if i click the dno its going to the gridview RowCommand event.

my requirement is i have another gridview & i need to bind the childrecords  with another grid view.
 
this is my code can anybody suggest me how can i achieve this

protected void gvDept_RowCommand(object sender, GridViewCommandEventArgs e)
LinkButton lbtn = e.CommandSource as LinkButton;DataRelation oDR = new DataRelation("Dept_Emp", oDS.Tables["tbl_Department"].Columns["DNo"], oDS.Tables["tbl_EmpDept"].Columns["DNo"], false);foreach (DataRow oDRDept in oDS.Tables["tbl_Department"].Rows)"DNo : " + oDRDept["DNo"].ToString() + " Name : " + oDRDept["DName"] + " Location : " + oDRDept["Location"];foreach (DataRow oDREmp in oDRDept.GetChildRows(oDR))


can anybody tel me how can i achieve this