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
275
LoadOnDemand and Postback
posted

I have a heirarchial grid that I would like to use LoadOnDemand with but I can't seem to get it to work. When I click on a button which posts back the form and changes the rows in the datasource then the second band doesn't appear.

The bands and columns are created in the aspx page and AutoGenerateColumns is set to false.

Here is a simplified version of my code

 Sub Page_Load

if not myGrid.IsXmlHttpRequest then

'-- I connect to the database. I dispose in the unload event.

End if

End Sub

sub btnSearch_click(ByVal sender ....

    dim ds as dataset
    ds = doSearch(txtSearch.text) 'In this function I retrieve the dataset from the database and set the datarelations.
    myGrid.datasource = ds

end sub

Sub myGrid_InitializeLayout

    myGrid.Bands(0).DataKeyField = "ID"
    myGrid.Bands(1).DataKeyField = "ID, ID2"

End Sub

Sub myGrid_InitializeDataSource

    if myGrid.IsXmlHttpRequest then

       'Connect to database. If this is called then I dispose in the pre_render event

        dim ds as dataset
        ds = doSearch(txtSearch.text)
        myGrid.DataSource = ds

    end if

End Sub

I'm not sure what is going wrong but in the InitializeRow event the second band doesn't seem to exist. Any Ideas?

  • 275
    posted

    I figured it out myself. In case anyone has the same problem this is what fixed it.

    In the InitializeDataSource event I put the following.

    if myGrid.isXmlHttpRequest then
        'Connect to database. If this is called then I dispose in the pre_render event

        dim ds as dataset
        ds = doSearch(txtSearch.text)
        myGrid.DataSource = ds

    else
         e.cancel = true
    end if

    I guess that prevents further processing which was clearing the other bands and column info specified in the aspx page.

     Amy