I have a grid containing say a Customer List and on the same page some controls and a button (Button3).
In the click event handler of Button3, I save a new entry to the database. As such I would need to refresh the grid to reflect that new entry.
The problem is the click event handler is fired after the InitiliazeDataSource event of the webgrid is called.
In the grid's InitiliazeDataSource I simply assign the grid datasource with a dataset (no call to DataBind() is made).
To reflect the newly added entry I tried to reassign the DataSource value with a more updated/latest dataset but it doesn't reflect on the browser. I called DataBind() expicitly and it worked. The only problem is my OnItemCommand event handler for the webgrid no longer triggers right after. I have an aspButton (say ButtonEdit) inside a template column. Whenever an explicit call to DataBind is made clicking ButtonEdit causes a callback but doesn't trigger the OnItemCommand event handler. Since the webgrid has been re-initialized then, succeeding clicks on ButtonEdit will work normally until Button3 is clicked again.
So if I'm not mistaken, calling Grid.DataBind() explicitly in code seems to messes up a lot of things and event handling seems to be one of them. Can someone confirm this? or any work-around? I think this is a common scenario though and calling DataBind over and over again within a postback/callback should in my opinion not cause any issues.
One workaround I could think of is find a way to ensure that my "save" processing comes before InitializeDataSource fires. Ideally it should be on my button click handler which comes unfortunately comes after the InitializeDataSource. This would prevent me from having to fill the dataset more than once nevertheless I think it would be worth looking into.
Thanks in advance for any comment.
I'm sad, yet another post on infragistics forum that perfectly describes my problem and it is completely ignored by IG support.
This post 22 months old, is there an answer?
My situation is similar -
on a command button in the grid, I display a web dialog window where the suer enteres some data. On a button click in that WDW, I update my database. Now I want to refresh my webdatagrid, but it fails as described above.
help!
Hi,
I have had a similar problem with the WHDG. Try:
WebDataGrid.Rows.Clear()
WebDataGrid.Databind()
By me, this forces the databind to do it's job.
Ed
I'm having a similar problem.The following did not work for us with a WedDataGrid:WebDataGrid.Rows.Clear()WebDataGrid.Databind()I can't say for sure if it works with a WHDG.
My scenario involves a DropDownList above the WebDataGrid that the user selects. On the postback, I want to alter the SqlDataSource and rebind the updated data to my WebDataGrid. I am not attempting to utilize the filtering built into the WebDataGrid, as the my DropDownList does not contain items found in the WebDataGrid.
I cannot get the data to update in the WebDataGrid for the life of me.
Any help would be greatly appreciated.
Thank You,Mike
I have some ideas on this one, but I would need to see some code like the datasource and code behind. You have to be very careful to check when the sqldatasource_selecting event is happening in your page life cycle although it doesn't sound like that is the problem because you would have seen updates on subsequent postbacks.