DEV GridView nesting, devgridview nesting
DEV has done a lot recently and wants to make the program look professional. So I have studied it a little.
This article only records how to click a row in the list to open the content of the associated sub-table in this row. The effect is as follows:
The implementation process is as follows:
1. In the designer:
Create an EntryView (create a new level) under MainView so that the gridControl contains two gridView entries.
Then open your Designer (Run Designer)
If you are only testing, or If Party A has no requirements for the beauty and ugliness, you do not need to set the settings.
2. Bind data
Like normal binding, gridControl. Datasource = DataSet. table [0];
The difference is that there must be two tables in this DataSet, and table1 and table2 must be the relationship between the master and slave tables (the main table has a field that is a foreign key from the table to form a relationship ), for example, it's not like it. It's a bit lazy.
Stored Procedure:
Select OutStockPlan. * from T_OutStock_Plan as OutStockPlan where OutStockPlan. BillDate <@ maxDate_Invo and OutStockPlan. BillDate> @ minDate_Invo
Select ospe. * from T_OutStock_Plan as osp
Left join T_OutStock_Plan_Entry ospe on osp. OnlyID = ospe. VoucherID
Where osp. BillDate <@ maxDate_Invo and osp. BillDate> @ minDate_Invo
A stored procedure returns two tables at the same time. The first statement returns the row of the primary table, and the second statement returns the row of the child table corresponding to the information of the primary table. As long as it is not too troublesome, You can execute it separately. I am still a little lazy.
Access execution:
WMSDS relationDS = this. _ WMSAccess. Select_OutPlanAndEntry_Relation (dateS, dateE); // executes the preceding stored procedure and returns a DataSet containing table1 and table2
DataRelation dr = new DataRelation ("Notification entry", new DataColumn [] {relationDS. t_OutStock_Plan.Columns ["OnlyID"]}, new DataColumn [] {relationDS. t_OutStock_Plan_Entry.Columns ["VoucherID"]}); // a new table relationship bound with the keys of two tables
RelationDS. Relations. Add (dr); // Add a table that is related to dataset
Front-end binding:
Grid_VoucherPlanList.DataSource = relationDS. Tables ["T_OutStock_Plan"]; // bind the master table to gridControl as a datasource.
Close.
Append: AllowOnlyOneMasterRowExpanded = True. Only one row can be expanded at the same time. If it is false, it can be expanded at will.
If you do not want to display the tab of the notification entry, set ShowDetailTabs to false. But do you want to expand a tab for Mao? Does it mean that a primary table can be expanded when associated with multiple sub-tables.
For GridView nesting
GridView2 can only be found in the row generation event of gridview1 and bound.
Gridview template column nesting gridview
GridView1.Rows [row]. Cells [column]
Or
You can add a template and use the TextBox Control and Button to obtain the above value.
Protected void Button1_Click1 (object sender, EventArgs e)
{
Int index = (GridViewRow) (Button) sender). Parent. Parent). RowIndex;
TextBox aa = (TextBox) GridView1.Rows [index]. Cells [7]. FindControl ("TextBox1 ");
String a = Convert. ToString (aa. Text). Trim ();
}