Hi,
I have an unbound webgrid that I create programmatically. The grid is populated with data programmatically and allows users to update cell values via direct cell editing and also allows a bulk change programatically.
All works fine until I try to read the values into a datatable in my code. The cell values that were changed directly by the user are ok, but the cell values changed programatically are not being recognised. The old values are being read into the datatable. I've tried setting the data changed property on the cell to true when it's updated in the code, but this is not being recognised either. I can't work out why it recognises the changes made directly by the user, but not those made programmatically. I can see the changes in the grid, but the code that reads from the table can't see them.
It's all done on server side.
Any suggestions on what may be occurring would be appreciated.
Regards
In cases like this, it really helps if you post your code. My hunch is that you're not updating your datasource before rebinding your grid. You should be using an UpdateRow or an UpdateRowBatch event handler. For more on that, see this thread:
http://forums.infragistics.com/forums/t/3021.aspx
Thanks for your reply. My grid is not databound though. Basically, I have a tab control to which I add tab items dynamically. To each tab item, I have to create a grid from scratch. It's all done dynamically because the number of tab items to add, and therefore grids to add, is data dependant.
I don't have access to my code at the moment, but it's really quite simple.
I have a grid to which users add values. They then hit a button which copies these values to the selected rows in the dynamically created grid. This is done simply by assigning the value of the source grid cells to the value property of the destination grid cells as follows:
destinationGrid.rows(i).cells.fromkey("key").value = sourceGrid.rows(i).cells.fromkey("key").value
destinationGrid.rows(i).cells.fromkey("key").datachanged = true
Visually, it all works fine, but later in my processing when I'm attempting to assign the new cell values to a datatable cell by cell, the old value is still stored in the value property for the updated cells. I do this as follows:
table.rows(i).item("key") = destinationGrid.rows(i).cells.fromkey("key").value
Even when I check the value of the datachanged property at this time, it's set to false. It's as though updating the cell programmatically does not trigger certain events that register the update.
Thanks
Again, without looking at your code, I'm left guessing. And whether you are databinding your grid or populating it programmatically, my hunch remains the same.
I've had similar problems when the code that populates my grid with its initial values is run without checking IsPostBack in an event that occurs after the update events. (Keeping in mind the fact that Infragistics controls do not always adhere to the event sequence one expects in .Net.)
In any case, for the benefit of the rest of us, please keep us posted.
I have a similar problem with the dynamically created grid, But to me I believe we need to create them and bind in on it of the asp.net page life cycle, if we databind in on load then the problem exists, trying to figure out any client side which supports changes done on to the grid. Please post incase anybody has solution for this problem great help!
Thanks,Chaitanya
I've been able to determine why my programmatic changes aren't persisting and it's to do with the page cycle. I build the grids on each page load event because the grids seem to go missing on postbacks otherwise.
The result of this is that the data is loaded before the code gets a chance to write the changes to the data table. The puzzling part to me is that, changes that are made by the user to the grid are persisted. Changes made by the user via the grid therefore must be treated differently than programatic changes. User interface changes are persisted whereas programmatic changes aren't.
For the short term (hopefully), I've resolved the issue by duplicating all changes to the grid to a datatable stored as a session variable. Instead of reading from the grid when the user chooses to save the changes, it reads from the session variable. It works fine, but I'd still like to know why the programmatic changes aren't being persisted when the user changes are.