Home > Net >  DataGridView master-slave table problem
DataGridView master-slave table problem

Time:05-10

 SQL="select * from v_" + from the Name, the Substring (1, from the Name. The Length - 1) + "order by" + from the Name, the Substring (1, from the Name. The Length - 1) + "ID". 
SqlItem="select * from v_" + from the Name, the Substring (1, from the Name. The Length - 1) + "Item" + "order by" + from the Name, the Substring (1, from the Name. The Length - 1) + "ItemID";
DataGridView dv=from the Controls. The Find (" DataGridView ", true) [0] as DataGridView.
DataGridView dvi=from the Controls. The Find (" dataGridViewItem ", true) [0] as DataGridView.
Dv. AutoGenerateColumns=false;
Dvi. AutoGenerateColumns=false;
The DataSet ds=new DataSet ();
SqlDataAdapter masterda=new SqlDataAdapter (SQL, mydate Conn);
Masterda. The Fill (ds, "v_ +" from the Name, the Substring (1, from the Name. The Length - 1));
SqlDataAdapter detailsda=new SqlDataAdapter (sqlItem mydate. Conn);
Detailsda. The Fill (ds, "v_ +" from the Name, the Substring (1, from the Name. The Length - 1) + "Item");
DataRelation base=new DataRelation (ZC,
Ds. Tables [+ "v_" from the Name, the Substring (1, from the Name.) Length - 1]. The Columns [from the Name, the Substring (1, from the Name. The Length - 1) + "ID"],
Ds. Tables [+ "v_" from the Name, the Substring (1, from the Name. The Length - 1) + "Item"]. Columns [from the Name, the Substring (1, from the Name. The Length - 1) + "ID"));
Ds. Relations. The Add (base);
Dv. The DataSource=ds;
Dv. DataMember="v_" + from the Name, the Substring (1, from the Name. The Length - 1);//set up the binding of the main table name
Dvi. DataSource=dv;//set up from the table data
Dvi. DataMember="ZC";//set up the binding of master-slave relationship table name

Run tip unable to create the field of ZC child list
An example of online copy

CodePudding user response:

I am VS2019 case seems to be 2008 how to modify

CodePudding user response:

I don't want to see, guo jiaobu code,
You should learn some new framework technology, don't use this kind of old-fashioned things, will make of you head pain

CodePudding user response:

Two layers architecture, don't write so deep, logic, and as I wrote before DELPHI less demanding of CS mode just fast data processing

CodePudding user response:

refer to the second floor morliz son hin reply:
I don't want to see, guo jiaobu code,
You should learn some new framework technology, don't use this kind of old-fashioned things, will make of you head pain

From the Name. The Substring (1, from the Name. The Length of 1) later I change a readable
 SQL="select * from v_Order order by OrderID"; 
SqlItem="select * from v_OrderItem order by OrderItemID";
DataGridView dv=from the Controls. The Find (" DataGridView ", true) [0] as DataGridView.
DataGridView dvi=from the Controls. The Find (" dataGridViewItem ", true) [0] as DataGridView.
Dv. AutoGenerateColumns=false;
Dvi. AutoGenerateColumns=false;
The DataSet ds=new DataSet ();
SqlDataAdapter masterda=new SqlDataAdapter (SQL, mydate Conn);
Masterda. The Fill (ds, "v_Order");
SqlDataAdapter detailsda=new SqlDataAdapter (sqlItem mydate. Conn);
Detailsda. The Fill (ds, "v_OrderItem");
DataRelation base=new DataRelation (ZC,
Ds. Tables [r]. "v_Order" Columns (" OrderID "),
Ds. Tables [r]. "v_OrderItem" Columns (" OrderID "));
Ds. Relations. The Add (base);
Dv. The DataSource=ds;
Dv. DataMember="v_Order";//set up the binding of the main table name
Dvi. DataSource=dv;//set up from the table data
Dvi. DataMember="ZC";//set up the binding of master-slave relationship table name

CodePudding user response:

You put the master-slave structure, and the requirement of data presentation, and provide detailed point out,

I give you to write a realization method of the class, if it is double view rendering, actually can use GridControl directly, rather than the two DataGridView,
The demand and present as a result, with no clear, so thinking clearly
  •  Tags:  
  • C#
  • Related