怎么读取datagrid主表以及子表数据
我现在使用一个DataGird绑定了一个dataset,dataset中两个表,一个主表,一个子表。数据已经可以显示啦,但是我不知道怎么获得它的数据。
//获得要显示的主表信息
string empSql = "select e.ep_id_int,a.id,[name],Gender, [Month],AssessBy,AuditingFlag,AuditingBy,auditingDate,superioid from EmployView as e left join hr_Assess_mst as a on e.ep_id_int=a.id where superioid=(select [name] from hr_staff_tbl where ep_id_int=@Empid) ";
SqlParameter empid = new SqlParameter( "@Empid ", DbType.String);
empid.Value = eid;
DataTable emp_tbl = dbhelp.GetDataTable(empSql, CommandType.Text, empid);
//获得要显示的子表信息
string assessSql = "select * from hr_Assess_dtl ";
DataTable assess_tbl = dbhelp.GetDataTable(assessSql, CommandType.Text);
assess_tbl.TableName = "Assess ";
DataSet ds = new DataSet();
//将表添加数据集中
ds.Tables.Add(emp_tbl);
ds.Tables.Add(assess_tbl);
//建立两个表之间的关系
ds.Relations.Add( "员工考核方案 ", ds.Tables[ "Employ "].Columns[ "id "], ds.Tables[ "Assess "].Columns[ "Id "]);
//绑定数据
dataGrid1.DataSource = ds.Tables[ "Employ "];
现在数据已经绑定好了,我就是不知道怎么来读取datagrid中的主表以及子表的数据!!!!!
请各位大哥大姐帮帮忙!!!!!急急急