jpetter
asked on
Is there a way to bind columns of a DataGrid to different datasources?
I have to display a summary report on our intranet. Since I used the DataGrid for the other reports I've created, I thought I could possibly use it for this as well. However, I really don't know if what I need to do can be done using the DataGrid. Each column in the grid would need to display a heading and number from a seperate query. So, I would think that I would then need to create a dataset for each query, and bind the successive, individual columns to the different datasets.
Does anyone know if this can be done, and if so, help me along in the right direction?
Thanks,
Jeff
Does anyone know if this can be done, and if so, help me along in the right direction?
Thanks,
Jeff
ASKER
tushar,
Thanks. Let me give it a try and I'll get back. Thx.
Jeff
Thanks. Let me give it a try and I'll get back. Thx.
Jeff
ASKER
tushar,
I think I have it so that it just about works the way I want it to. Thanks.
I do find something strange that I have so far not been able to figure out. Though I should only display one row, which is the summary information, I am displaying eleven rows (or six if I rem out the AlternatingItem). Would have any idea what could be causing that? I've pasted the ItemDataBound event below.
Thanks,
Jeff
Private Sub DataGrid1_ItemDataBound(By Val sender As Object, ByVal e As System.Web.UI.WebControls. DataGridIt emEventArg s) Handles DataGrid1.ItemDataBound
Dim counter As Integer
For counter = 0 To 9
Select Case e.Item.ItemType
Case ListItemType.Item
e.Item.Cells(counter).Text = SummaryArray(counter)
'Case ListItemType.AlternatingIt em
' e.Item.Cells(counter).Text = SummaryArray(counter)
End Select
Next
End Sub
I think I have it so that it just about works the way I want it to. Thanks.
I do find something strange that I have so far not been able to figure out. Though I should only display one row, which is the summary information, I am displaying eleven rows (or six if I rem out the AlternatingItem). Would have any idea what could be causing that? I've pasted the ItemDataBound event below.
Thanks,
Jeff
Private Sub DataGrid1_ItemDataBound(By
Dim counter As Integer
For counter = 0 To 9
Select Case e.Item.ItemType
Case ListItemType.Item
e.Item.Cells(counter).Text
'Case ListItemType.AlternatingIt
' e.Item.Cells(counter).Text
End Select
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
tushar,
That last code snippet with the footer did it. Sorry I didn't make myself more clear. I had misunderstood the way the event fired, and was looping in hopes of populating the proper cell with the proper element from the array.
Thanks again for your help,
Jeff
That last code snippet with the footer did it. Sorry I didn't make myself more clear. I had misunderstood the way the event fired, and was looping in hopes of populating the proper cell with the proper element from the array.
Thanks again for your help,
Jeff
Nice to have you going Jeff.. :)
// lets say you want to Feel Column 0 of your DataGrid based upon some value of Column 1...
// run your query on GetData(..) function and return result as String
private void DataGrid1_ItemDataBound(ob
{
switch( e.Item.ItemType )
{
case ListItemType.Item:
case ListItemType.AlternatingIt
e.Item.Cells[0].Text = GetDataFunction( e.Item.Cells[0].Text );
break;
}
}
-tushar