Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
hierarchical grid losing data when parent row is expanded
posted

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.Click
GetData()
Me.grdReport.DataSource = GetData.Tables(0)
Me.grdReport.DataBind()
End Sub

Public Function GetData() As DataSet

Dim ds As New DataSet

Dim TicketsAdapter As New CTReportingTableAdapter

Dim Tickets As TicketSearch.CTReportingDataTable

Dim OneTicket As TicketSearch.CTReportingRow

Dim ItemsAdapter As New CT_ItemsReportingTableAdapter

Dim Items As New TicketSearch.CT_ItemsReportingDataTable Tickets = TicketsAdapter.GetData(Me.ddlAssignedTo.SelectedValue, Me.ddlEnteredBy.SelectedValue, Session("SearchTicketFrom"), Session("SearchTicketTo"), Me.ddlTicketType.SelectedValue, Me.ddlTicketStatus.SelectedValue, Me.ddlBU.SelectedValue)

ItemsAdapter.ClearBeforeFill = True

For Each OneTicket In Tickets

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

 

Parents
  • 220
    posted

    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?

Reply Children
No Data