Click here to Skip to main content
15,924,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a checkbox inside a grid view.When i click on save button,i check at code behind which check boxes are checked to save record in db.butCheck box.checked property is always false.

foreach (GridViewRow row in GridView1.Rows)
{
CheckBox chbx = (CheckBox)row.FindControl("chk1");
if (chbx.Checked)
{
}}
However it works fine in Mozilla but not in IE
Posted
Updated 5-Jun-12 21:02pm
v2
Comments
[no name] 6-Jun-12 4:02am    
show ur aspx code
ashishdhingra 6-Jun-12 4:10am    
asp:TemplateField HeaderText="Select ">
<itemtemplate>
<asp:CheckBox ID="chk1" runat="server" />

<itemstyle width="20px">

1 solution

You sure you put the GridView bind code in page IsPostback property?

If you do not, then on every postback, page load would happen and grid would refresh rebind - loosing all the changes.
C#
if(!IsPostback)
{
 //...
 //...
 // GridView DataBind
 //...
}
 
Share this answer
 
Comments
ashishdhingra 6-Jun-12 6:03am    
yes sure....my code is working in all other browsers..but not in IE.
Sandeep Mewara 6-Jun-12 7:14am    
Did you DEBUG and see the execution? use F11. AFAIK, there is no known issue with checkbox in grid with IE.
ashishdhingra 7-Jun-12 2:39am    
yes i debugged it..there is no issue with checkbox..i came with another scenario.i was using html button and in page load with the hidden variable i was calling a save method which was checking checkbox's check or not..if i use server side button,then on click is not fired in IE,where as in other browsers it is working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900