I have created a hierarchical dataset and bound my grid to it. My grid is in a webasynchrefreshpanel.If I put e.Row.Expand(True) in the Initialize Row event, I can see the child rows.If the rows aren't expanded, and I click to expand a row, I can see it start to show the child row, then it posts back and all I get is the NoDataMessage.The same behavior happens if I try to sort or group by in the grid.If I try to export the grid to excel before I expand a row, the excel file is empty.
What am I missing or doing wrong?Code:
Private Sub btnGenerate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGenerate.ClickGetData()Me.grdReport.DataSource = GetData.Tables(0)Me.grdReport.DataBind()End Sub
Dim ds As New DataSet
Dim Tickets As TicketSearch.CTReportingDataTable
Dim ItemsAdapter As New CT_ItemsReportingTableAdapter
ItemsAdapter.ClearBeforeFill = True
ItemsAdapter.FillBy(Items, OneTicket._Ticket_)
ItemsAdapter.ClearBeforeFill = False
Next
ds.Tables.Add(Tickets)
ds.Tables.Add(Items)
ds.Relations.Add("Ticket", ds.Tables(0).Columns("Ticket#"), ds.Tables(1).Columns(0))
Return ds
end function
OK. I think I solved 90%. I did not realize that you have to put the datakeys for the bands in the initilize layout event.
I found it in the documentation under "using xml load on demand".
Me.grdReport.Bands(0).DataKeyField = "Ticket#"
Me.grdReport.Bands(1).DataKeyField = "ti_TicketNumber,ti_Number"
and in the Initialize DataSource event
Me.grdReport.DataSource = GetData()
The only problem I have now is that when I click on the button to expand the row, it looks like it is rebinding to the datasource and then doesn't expand the row.
As a test I expanded all rows in the initialize row event, they show expanded just fine. If I then manually collapse some and then try to expand them again, they all expand, which means the initialize row event is firing again, which tells me that the grid is rebinding (I think).
Any ideas?
I figured it out (finally).
I had to set the Me.UltraWebGrid1.DisplayLayout.ReadOnly = LevelTwo. It was set to Not Set.