[RESOLVED] DataGrid Checkbox Column Unchecked!!
Hi there,
I am working on a datagrid that has a column with checkboxes… the checkboxes should be checked when the page loaded. The problem is that whenever I trigger a postback, all the checkboxes will be unchecked!!
I don’t know what is causing this or what should I do to prevent it from unchecking the checkboxes.
Any idea?
Re: DataGrid Checkbox Column Unchecked!!
Nina,
We are going to need more information than what you have given there.
Are the checkboxes tied to back end data, or are you simply looping through them when the page posts back?
Can you show the code/markup that you are using?
Gary
Re: DataGrid Checkbox Column Unchecked!!
Quote:
Originally Posted by
NinaWilliam
Hi there,
I am working on a datagrid that has a column with checkboxes… the checkboxes should be checked when the page loaded. The problem is that whenever I trigger a postback, all the checkboxes will be unchecked!!
I don’t know what is causing this or what should I do to prevent it from unchecking the checkboxes.
Any idea?
If you are checking the checkboxes by coding, then the data binding to the textbox should occur in If not Page.PostBack method.
If you are having your method in page load method without
Code:
If Not Page.IsPostBack Then
'Binding code
End if
Then the grid will repopulate the data and the checked state will lost..
Hope this helps
Re: DataGrid Checkbox Column Unchecked!!
Thank you guys for your reply ^_^
I was doing something wrong in the code *_*
These lines solved it
Dim chkSelected As CheckBox = e.Item.FindControl("chkSelection")
chkSelected.Checked = True
Have a nice day
Re: [RESOLVED] DataGrid Checkbox Column Unchecked!!
When using FindControl, you should always do a null/nothing check before accessing the members of that object, otherwise you might get an exception.
Gary
Re: [RESOLVED] DataGrid Checkbox Column Unchecked!!
Thank you Gary ^__^
I appreciate your advice.
Have a good day :)