DataColumn parentCol; DataColumn childCol; // Code to get the DataSet not shown here. parentCol = DataSet1.Tables["Customers"].Columns["CustID"]; childCol = DataSet1.Tables["Orders"].Columns["CustID"]; // Create DataRelation. DataRelation relCustOrder; relCustOrder = new DataRelation("CustomersOrders", parentCol, childCol); // Add the relation to the DataSet. DataSet1.Relations.Add(relCustOrder); DataGrid1.DataSource=DataSet1; DataGrid1.DataBind();
在SQL里解决呀,select a.a1,b.b1 from a,b where a.id=b.id
我现在是各取每个表的个别字段合并成的datagrid
一个datagrid显示两个表里取的个别字段,当然这两个表是有关系的
select a.a1,b.b1 from a,b where a.id=b.id 这样的SQL不能满足个别字段吗? 楼主好像还是没说清自己的意图
DataColumn childCol;
// Code to get the DataSet not shown here.
parentCol = DataSet1.Tables["Customers"].Columns["CustID"];
childCol = DataSet1.Tables["Orders"].Columns["CustID"];
// Create DataRelation.
DataRelation relCustOrder;
relCustOrder = new DataRelation("CustomersOrders", parentCol, childCol);
// Add the relation to the DataSet.
DataSet1.Relations.Add(relCustOrder);
DataGrid1.DataSource=DataSet1;
DataGrid1.DataBind();
这样的SQL不能满足个别字段吗?
楼主好像还是没说清自己的意图
现在的项目是分层开发的,如果用他们的方法,该怎么写的,麻烦大家了?
或者你看看这个网站你就明白了。
http://www.dotnetjunkies.com/Tutorial/47792CB0-0990-4BD8-BF84-B6063C4C9BBC.dcik
谢谢,另我好象还跟你留了言~