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
181
How to force a DataBind when using LoadOnDemand?
posted

 Hi eveyone!

I have this problem, so I'll appreciate very much any help (hopefully a code example).

The settings:

  • I have to display a big bunch of data in a webGrid, so I had to use the LoadOnDemand feature.
  • The data is stored in a Session variable and is provided to the grid using this handler for the InitializeDataSource event:

    Protected Sub MyGrid_InitializeDataSource(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.UltraGridEventArgs) Handles MyGrid.InitializeDataSource
        ' See if this is a first load, or if this is a postback that is not an AJAX postback made by the WebGrid
        If Not IsPostBack AndAlso Not MyGrid.IsXmlHttpRequest Then
            Dim dt As DataTable
            Dim pizarra As New Vbc.Pizarra 
            dt = pizarra.GetMyData(Session.Item("MyEntCode"), My.User.Name)
            Session.Add(DS_OFERTAS_COMPRA, dt)
        End If

        MyGrid.DataSource = CType(Session("GridDS"), DataTable)
    End Sub
 

The problem: 

Besides displaying the data, I have to provide to the end user a way to refresh that data based on certain parameters he provides through some textboxes. Once the user clicks a "Refresh" button, the following code is executed:

                    If IsPostBack AndAlso Not MyGrid.IsXmlHttpRequest Then
                        Dim pizarra As New Vbc.Pizarra  
                        Dim dt As DataTable

                        dt = pizarra.GetMyData(Session.Item("MyEntCode"), My.User.Name)
                        Session.Item("GridDS") = dt

                        MyGrid.DataBind()
                    End If

The idea was to reload the data into the grid with the new dataset (according with the parameters given by the user), however the grid doen't reload the data until a new postback. 

How can I force this databind to have the data in the grid refreshed everytime the user click my "Refresh" button?

 

Thanks in advance for your help!

 

Parents Reply Children
No Data