473,322 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Multiple DataSouce for a DataGrid

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
1 1389
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official...
1
by: Jim Heavey | last post by:
Can I bind 3 controls to 3 different datatables? I have a datagrid with a databound column and 2 DropDownList. I set the datasource for the datagrid to Table1 and the DataBoundColumn to...
1
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
1
by: Craig Banks | last post by:
If a row of data in a dataset has a lot of columns the row displaying the data in a datagrid will run way off the screen. What I'd like to do is display a row of data over several datagrid rows so...
5
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
1
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been...
4
by: Dave Edwards | last post by:
I understand that I can fill a datagrid with multiple queries, but I cannot figure out how to fill a dataset with the same query but run against multiple SQL servers, the query , table structure...
0
by: dbuchanan | last post by:
How do I make multiple DataGridTableStyles serve the same table? (I can get multiple styles for the same datagrid, but not multple styles for the same *table* on the same datagrid) I want to do...
0
by: rn5a | last post by:
A DataGrid control displays records from a SQL Server 2005 DB table. The AllowSorting property of the DataGrid has been set to True & the SortExpressions of the BoundColumns have been set to the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.