Hi
I am using infragistics 2008 ultrawebGrid in my page and i in one of the pages i want to add a checkbox column to the grid. Ok, ths was fine, the problem its when y use paging and i want the user to check any rows he want; when he want to change the page, changes ok but if i return to the old page, the rows that i checked they are not longer checked.
I thought it was the WARP but taking it out it doesnt work. I bind a dataset to the grid in code behind when i push the button "SEARCH". I use a DataSet as datasource and i dont manage any event of the grid (i think is no use to manage it)
Thanks for your help.
You need to save the value of each underlying cell in this column (which represents the checked state of each checkbox), likely using the UpdateRow, UpdateRowBatch, UpdateCell, or UpdateCellBatch events of the grid. Which event you use depends on how often you want updates to be processed, whether or not you're using the grid's built-in AJAX functionality, and if not using AJAX if you want to immediately trigger a postback or wait until a postback is triggered in some other way.
What's happening is that, when you switch pages, you're implicitly re-binding the grid so that it displays the desired page's data. When you go back to the first page, you're binding to the first page's rows again. A side-effect of this is that any updates that were performed but not saved are lost.
Hi Vince,
I am new to Infragistics. I am running into the same problem "CheckBox lost state with WebGrid paging ". I know the issue is what you have describe here but do not know how to implement your suggestion.
Would you please provide example or code or more details on how to "save the value of each underlying cell in this column (which represents the checked state of each checkbox), likely using the UpdateRow, UpdateRowBatch, UpdateCell, or UpdateCellBatch events of the grid. "
Thank you,
The most-straightforward implementation that I've seen involves storing a List<T> in Session state, where the data type stored matches the data type of the DataKey field in the grid's data source. As checkboxes were checked, in the UpdateRow event, (the grid's AJAX functionality happened to be enabled) the application added the row's DataKey to the list, and as the checkboxes were unchecked, that DataKey was removed from the list. In the InitializeRow event, if the row's DataKey appeared in the list, the checkbox would be rendered to the page as checked, otherwise it would be unchecked.
I don't have the sample availalbe any longer, since it was another customer's sample.
This is simply one possible implementation, by the way. The most important thing is that you make use of the grid's events to persist the checkbox values, and to re-apply those values when the grid is rebound.
Thank you for your help. I will have to change it from Template to bool as suggested by you.
kbapodara,
The CheckedChanged event doesn't sound to be correct, and suggests that you're using checkboxes added as ASP.NET CheckBox controls in a templated column of WebGrid. The example I provided uses the grid's built-in ability to show a checkbox when the underlying data is a boolean value.
I recommend you use a boolean WebGrid column, instead of a templated column containing a CheckBox control. Using a templated column in this scenario will make it significantly more difficult to accomplish your goal, due to the order in which events need to occur.
hi Vince,
Thanks for your prompt reply.
in existing code, I am saving checkbox value to database in CheckedChanged event. so, it should save data right away. I debug that successfully. ie. it is saving checkbox value as intended. here is a code for that.
protected void chkAccept_CheckedChanged(object sender, EventArgs e) Control)sender, lblInformActivity);
{
mclsMainActiveActivityWorkPackage.ProcessTransactId = mclsMainActiveProcessProjectDeliverableAdhoc.CurrentProcessTransactId;
mclsMainActiveActivityWorkPackage.PerformAcceptUnacceptActivityWorkPackage((
}
Also, I noticed while debugging that when PageIndexChanged event fires, data loses its state since, it accesses new ID but takes old checkbox state. ie. if moving from page 1 to page 2, it takes id of record on page 2 but checkbox state of page 1 (existing one).
Regards,