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
995
How to prevent the grid to databind?
posted

Hello,

I have two webgrid, depending on a checkbox, one is visible and the other one is not visible.
However, the event DataBinding is hit for both grid all the time which is not good for the performance.

When I debug my code I can see that it always go first to the databinding event and then to the "Checkchanged" event of my checkbox where I set the visibility of each grid to true or false.

How can I prevent  a grid from databinding?
Thanks

Parents
  • 45049
    posted

    If you don't want to databind WebGrid, you need to avoid doing three things:

    • Don't handle the InitializeDataSource event.  If you handle this event, The grid will implicitly call the DataBind() method once the event finishes.
    • Don't connect a DataSource object (such as SqlDataSource or ObjectDataSource) to your grid using the grid's DataSourceID property at design-time.  If this property is set to point to a valid DataSource control, the grid will databind to it early in the page lifecycle.
    • Don't call the DataBind() method of the grid.
Reply Children