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
Loading

Jignesh TrivediRank #16 · 50.3K reputationPosted Jun 6, 2012, 8:20 PM EDT
I have tryed it it work fine for me in all browser.
I used code in aspx.
protected void btnTest_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox chbx = (CheckBox)row.FindControl("chkSelect");
// DO YOU CODE.
}
}
Hope this help you.
ashish dhingra11 reputationPosted Jun 6, 2012, 10:39 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Jun 6, 2012, 11:09 PM EDT
Can please share pieces of code?
Are you use HTML submit button? If yes so I think you can find all control using "Request.Params".
Request.Params is take name as key it retun value on and off.
hope this will help u.
ashish dhingra11 reputationPosted Jun 6, 2012, 11:41 PM EDT
{
if (Request["hid1"] != null && Request["hid1"].Length>0 )
{
save();
}
else
{
bindgrid();
}
}
Save method code is written above in first post.
Aspx code:
asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" OnPageIndexChanging="ChangeGridView" PageSize="25" >