Multiple DataSouce for a DataGrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How to bind Multiple results into a datagrid.

For example Assume the values for dsCustCode.Tables(0).Rows.Count = 4,and
the values are "'Val1','val2','val3','val4'" in the below loop

In the above situation four datasource needs to be bind in the grid. I know
the below is binding the last value's (Val4) datasource in the DataGrid

For iCountCustCode = 0 To dsCustCode.Tables(0).Rows.Count - 1
CusCode =
dsCustCode.Tables(0).Rows(iCountCustCode)("CustCode").ToString ' say the
values are 'Val1','val2','val3','val4'
DataGrid1.DataSource = _Dac.GetOrders(CusCode, ControlNum,
AppLast, AppFirst, AppSocial, CaseNum) 'assume ControlNum, AppLast, AppFirst,
AppSocial, CaseNum are null
DataGrid1.DataKeyField = "RECORD_NUMBER"
DataGrid1.DataBind()
Next

if http://www.codeproject.com/aspnet/DataGridMultipleResultset.asp helps,
then let me know how to modify the sample code according to my requirement.
 
Actually, your code is binding every one in the loop, you only get to see
that last one because that's the last one before the loop ends.

if you have set your datagrid up correctly, you do NOT NEED A LOOP.

Just assign the datasource to the grid, and call it's DataBind method one
time.
Peter
 
Back
Top