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
100
WebGrid not binding data when dynamically defining columns at runtime.
posted

Hi,

I'm having a problem binding a DataTable to a WebGrid.  This is the setup:

 There's a button on the page that causes a postback.  And during the postback in the event method, I dynamically define each UltraWebColumn and then add each column to the WebGrid.  Then after each column is defined, I assign the datasource to the DataTable and then execute the WebGrid.DataBind() method to bind.

 So, this is the issue.  When I click the button for the first time, no data is rendered to the page.  But, the WebGrid will render data when the button is clicked a second time and any other time after.  But when I clear the webgrid at runtime then click the button to render the grid, no data is rendered again until I click the the button a second time.

 Does anyone have an idea why this might be happening?  Thanks.