hi any body tell me that if i have multiple tables in dataset and i want to bind only one to datagrid ,how can i do that?
dataset problem
Collapse
X
-
Tags: None
-
you just create a dataadapter.... ...fill the dataset table you want like following.....Originally posted by Hasan Afridihi any body tell me that if i have multiple tables in dataset and i want to bind only one to datagrid ,how can i do that?
[CODE=vbnet]
myDataAdapter.F ill(myDataset," myTableNameInDa taset")
[/CODE]
now bind your grid as usual....
[CODE=vbnet]
myGrid.Datasour ce=myDataset.Ta bles("myTableNa meInDataset")[/CODE]
next time you can fill another table with that same Adapter.... -
you can use table index for select a particular table from the dataset
eg:
SqlDataAdapter da=new SqlDataAdapter( "SELECT ClientName,IDCl ient FROM tbl_ClientDetai ls WHERE IDClient=140;SE LECT IDClient,SiteNa me FROM tbl_SiteDetails WHERE IDClient=140",c on );
DataSet ds=new DataSet();
da.Fill(ds);
if you want to select the first table, then you can use
DataGrid1.DataS ource=ds.Table[0];
DataGrid1.DataB ind();
else
if you want to select the second table then use
DataGrid1.DataS ource=ds.Table[1];
DataGrid1.DataB ind();Comment
Comment