Hi,
We have found the following behavior with Web Grid, and want to confirm if the same is a bug.
Created an Unbound column of CheckBox Type, and placed a 'Test Postback' on the page (outside the WebGrid).
Check one or more Check Boxes
Click 'Test Postback'
It works fine for the first postback.
User sees Check Boxes selected still.
Click 'Test Postback' again
This empties unchecks all Check Boxes in the Column.
Can somebody tell me if this behavior is by design or is a bug?
Also, is there any solution as we need to keep the CheckBox selection as is across all postbacks (Except converting the unbound column to a bound column and preserving its state in source data object).
Regards,
MPVBRao.
Hi you can resolve this problem with the property ViewState of .NetFrameWork, you can create a datatable and Save in the ViewState Property
First initialize the datatable only in the first postback of ther form:
Dim dt As New DataTable()
dt.Columns.Add(New DataColumn(<KeyOfDatasource>, GetType(Decimal)))
dt.Columns.Add(New DataColumn(<state of checkbox>, GetType(Boolean))) For Each row As GridRecord In webdatagrid.Rows Dim dr As DataRow = Nothing dr = dt.NewRow() dr("IdFact") = If(IsDBNull(row.Items(1).Value), "", Trim(row.Items(1).Value)) dr("Estado") = False dt.Rows.Add(dr) Next 'Store the DataTable in ViewState ViewState("CurrentTable") = dt
then you can add a client event in the aspx form:
function webdatagrid_Editing_CellValueChanged(sender, eventArgs) { ///<summary> /// ///</summary> ///<param name="sender" type="Infragistics.Web.UI.WebDataGrid"></param> ///<param name="eventArgs" type="Infragistics.Web.UI.CellValueChangedEventArgs"></param>
if (eventArgs.get_cell().get_column().get_key() == "UnboundCheckBoxField_0") { var callbackObj = sender._callbackManager.createCallbackObject(); sender._callbackManager.execute(callbackObj); }
}// -->
then in ther server side create a rowupdated event and then you save the new status of the checkbox edited by the user:
Protected Sub webdatagrid_RowUpdated(sender As Object, e As RowUpdatedEventArgs) Handles webdatagrid.RowUpdated Dim dt As DataTable dt = DirectCast(ViewState("CurrentTable"), DataTable) For Each row As GridRecord In wdgFacturas.Rows dt.Rows(row.Index)(<State of Checkbox>) = row.Items(0).Value 'cell with the value edited by the user Next ViewState("CurrentTable") = dt End Sub
Then you need create other event for example RowSelectionChanged
Protected Sub webdatagrid_RowSelectionChanged(sender As Object, e As SelectedRowEventArgs) Handles webdatagrid.RowSelectionChanged
Dim dt As DataTable dt = DirectCast(ViewState("CurrentTable"), DataTable) For Each row As GridRecord In wdgFacturas.Rows dt.Rows(row.Index)(<state of checkbox>) = row.Items(0).Value Next ViewState("CurrentTable") = dt
sbSeteaEstadoCheckBox() ' HERE CALL A METOD FOR INITIALIZATE THE CHECKBOX ROWS IN THE DATAGRID
end sub
AND CREATE THE METOD TO INITIALIZE THE VALUES
Private Sub sbSeteaEstadoCheckBox() Try Dim dt As DataTable dt = DirectCast(ViewState("CurrentTable"), DataTable) Dim nose As Integer = 0 For Each row As GridRecord In webdatagrid.Rows row.Items(0).Value = dt.Rows(row.Index)(<state of checkbox>) nose += 1 Next Dim testing = 0 Catch ex As Exception
End Try End Sub
With this you save in a view state datatable the selections of the user and then you pass this values on every row selection change
I see two options. One is to persist the value of the checkbox on each row in some fashion. The other is to not use the InitializeDataSource event, and thus take direct control as to when you call the grid's DataBind() event."
so, which event do we have access to the datagrid rows and its values before InitializeDataSource is called to rebind to persist value of the checkbox?
The below is the conversation on the support case I opened regarding this issue.
Support Request CAS-14180-IB3NB9
Your case has been closed.
If you feel that your issue is still not resolved, you can reopen this case within the next 30 days, using the "Reopen" button when viewing this case at the "My Support Requests" page of our website.
After 30 days, the case cannot be reopened. If you need further assistance after this timeframe, please submit a new support request, and refer to this case number.
Please take a moment to provide feedback to Infragistics regarding the quality of support you have received regarding this case, using the following web page:
http://www.zoomerang.com/survey.zgi?p=WEB2282WD5HGKE
Hello,
Thank you for getting back with an update on the issue. From the description of the issue it seems that you want to get the status of the checkbox even after postback.
I would request you to please save the state to any variable or hiddenField so that it can be latter on reset and you can retrieve it.
This is the expected behavior and in order to get the state you would have to save it.
You can refer the online help articles that I have provided in the last reply.
I apologize for the inconvenience that this might cause you.
Sincerely,GauravDeveloper Support Engineer
Thank you for submitting your issue with Infragistics Developer Support.
From the description of the issue and the forum link that you have prvided it seems that the checkbox state in the unbound column in WebGrid is getting lost after the second postback and also you are not getting the checked state after the first postback however, they appear checked.
I would like to inform you that this is a known issue. As you have the Unbound checkbox column in the WebGrid it keeps state checked because of the viewstate property but it is only for the display purpose. But if you again do a postback then it would not get the checkboxes as checked because before second postback you have not changed the state.
Now if you want that the state should persist across numerous postbacks then you would have to save the modified state of the checkbox either to the database or to any other data source from where you can again maintain the state.
For updating you can refer the following knowledge base article:
<http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=1104&_ga=2.147349239.1913332359.1564406253-1977778533.1538057382><http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=3455&_ga=2.147349239.1913332359.1564406253-1977778533.1538057382><http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=5937&_ga=2.147349239.1913332359.1564406253-1977778533.1538057382>
Hope this will help you.
This case has been submitted as a trial case. While we will naturally get to this as quickly as possible, we are sure you understand that our priorities are first to paid priority support customers, then to paid customers, and then to trial customers. We know that once you are finished evaluating our product(s), and become a paying customer, you will appreciate the order in which we have set these priorities.
If you have a license key, please register it to your Infragistics member profile at the following page:
<http://devcenter.infragistics.com/Support/KnowledgeBase.Aspx?_ga=2.147349239.1913332359.1564406253-1977778533.1538057382>
Once you have registered your license key, future support requests you submit for the corresponding version of the product will be connected to the appropriate level of support for that license.
If you are unable to register your license key for some reason, such as that it is already registered to another user, please contact our Registrations department at the following email address: registrations@infragistics.com
Checkbox state is being lost in second Postback.
We have a grid for which InitializeDataSource event is handled,
It contains an unbound editable checkbox column.
When user selects one or more checkboxes in the column and clicks a button to postback, it work fine for the first time and displays the checkboxes checked properly.
When user click the button postback again, the resulting screen clears the checkboxes, and through code also we are unable to get its checked state as shown before the second postback.
Also please refer to 'Steps to Reproduce'
Could you tell me if this behavior is by design or is a bug?
Reference: https://es.infragistics.com/community/forums/f/ultimate-ui-for-asp-net/67715/ultrawebgrid-checkbox-event-problem#67715
As said by Vince McDonald on the above forum thread, if the grid is rebinding in every postback (as we are handling InitializeDataSource event), it has to empty checkboxes even for the first time too, but it is persisting values for the first, not persisting there on.
Could you tell me if this behavior is by design or is a bug?, and any fix if available.
A sample page to reproduce the behavior is attached.
Thanks for the update.
I raised a support case for this, and will post the complete conversation here once it gets resolved.
I have double checked this problem with development and this is considered not a bug. Depending on your scenario (I am assuming you are using InitializeDataSource event) you may need to persist manually (with code) the values of the checkboxes - this can be for example ArrayList or List of boolean values in Session / Cache / ViewState and then restore, since databinding essentially clears grid row data.
I think Vince described that best with this
<quote>
"Since you're using the InitializeDataSource event, the grid is implicitly calling DataBind() on every postback. Since you're not persisting the value in these checkboxes in any way, they're lost on the postback that occurs after the postback where they were changed. I see two options. One is to persist the value of the checkbox on each row in some fashion. The other is to not use the InitializeDataSource event, and thus take direct control as to when you call the grid's DataBind() event."
</quote>