Hi,
In my gridview i have put checkbox as checked but on button click it is coming as false.
here is my code:
<%#Container.DataItemIndex+1%>
------------------
protected void btn_rights_submit_Click(object sender, EventArgs e)
{
try
{
foreach (GridViewRow row in grdv_rights.Rows)
{
CheckBox chk = (CheckBox)row.FindControl("chkSelect");
if (chk.Checked)
{
lbl_user_rights.Text = "test";
}
}
}
catch(Exception ex)
{
obj_db.GetErrorFile("btn_rights_submit_Click", ex.Message);
}
}
{
try
{
foreach (GridViewRow row in grdv_rights.Rows)
{
CheckBox chk = (CheckBox)row.FindControl("chkSelect");
if (chk.Checked)
{
lbl_user_rights.Text = "test";
}
}
}
catch(Exception ex)
{
obj_db.GetErrorFile("btn_rights_submit_Click", ex.Message);
}
}
please help..

Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted Feb 18, 2014, 7:35 PM EST
rachayita jaiswal182 reputationPosted Feb 18, 2014, 8:13 PM EST
this code i created:
CheckBox chk = (CheckBox)row.FindControl("chkSelect");
if (chk.Checked)
{
lbl_user_rights.Text = "test";
}
what's wrong in this?Plz tell me
rachayita jaiswal182 reputationPosted Feb 18, 2014, 8:40 PM EST
Gridview Id was creating problem.
ahsan iqb5 reputationPosted Feb 18, 2014, 9:54 PM EST
set your button property: AutoPostBack = True.
That's all.
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Feb 18, 2014, 11:31 PM EST
what prblm you are facing with grid id.
rachayita jaiswal182 reputationPosted Feb 18, 2014, 11:36 PM EST
nothing i just changed gridview id name from "grdv_rights" to "grdv_questionsright" and it started working.
It strange for me but this was the only issue.
:)
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Feb 18, 2014, 11:37 PM EST