By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,722 Members | 1,264 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,722 IT Pros & Developers. It's quick & easy.

Multiple DataSouce for a DataGrid

P: n/a
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)("CustCod e").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/Da...eResultset.asp helps,
then let me know how to modify the sample code according to my requirement.

May 9 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Waran" wrote:
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)("CustCod e").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/Da...eResultset.asp helps,
then let me know how to modify the sample code according to my requirement.

May 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.