how to bind more that one table with datasource property in dgv
Dear Sir,
Thanks for ur goods help. but now i have another problem in datasource property that is
i want to binding more than one table so that all table's data rows can be displayed in datagridveiw control.
suppose
i have two table as per order no..
idefine like that
dgv.datasource=table (orderno -1)
dgv.datasource=table (orderno-2)
but it displayed only last table(order-2) data in datagridwview control
but i want both table 1 and 2 data to be shown in datagridview..
thank & regards
Debasis
Re: how to bind more that one table with datasource property in dgv
if it is a father children relation, you cannot do that in a normal DataGridview, you have to switch back to DataGrid 2.0 if you want both in same grid (you will need to get a dataset with the two table and the relations of the two and then use the dataset as datasource of the DataGrid).
Using DataGridView requires we add two of them one for the father table and one for the children. We simply populate the children gridview after retrieving associated records based on the selection of a row of the first Gridview.
If instead it is fine to show only one datatable at a time using a single source
and switching between tables without reloading from real db, you could use a dataset and change the datamember property at runtime (an example is here:
http://msdn.microsoft.com/en-us/libr...atamember.aspx )
if instead it is a different relation, and ou can have a single table as result
1)if it is like where each row can have as columns the selected columns of first Table AND the selected columns of the second table, you can achieve that resultset using a Cross Join.
2)if you have same columns and you want the rows of first table and Also the rows of second table, you should have a look at Union and at Union All clauses to construct the appropriate datatable.
Re: how to bind more that one table with datasource property in dgv
Hello
you can bind to one or multiple data sources with Grid.DataSource property with simultaneous adding of objects with Grid.Rows.Add() / Row.Add() methods.
http://www.******.com/en/net-suite/n...adding-objects
hope this will help you.