I have cross checked the code and able to get true false as per the checkboxes check. Below is the sample code.
HTML
<div>
<asp:GridView ID="gvChecks" runat="server" AutoGenerateColumns="false" OnRowUpdating="gvChecks_RowUpdating"
CssClass="mGrid" onrowcancelingedit="gvChecks_RowCancelingEdit"
onrowediting="gvChecks_RowEditing">
<Columns>
<asp:TemplateField HeaderText="UploadDocID" ItemStyle-Width="25" Visible="false">
<ItemTemplate>
<asp:Label ID="lblUploadDocID" runat="server" Text='<%#Eval("UploadDocID") %>' Width="25"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Description">
<ItemTemplate>
<asp:Label ID="lblFileDescr" runat="server" Text='<%#Eval("FileDescr") %>' Width="500"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CheckResult" Visible="false">
<ItemTemplate>
<asp:Label ID="lblCheckResult" runat="server" Text='<%#Eval("DocValid") %>' Width="50"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Yes">
<ItemTemplate>
<asp:CheckBox ID="cbYes" runat="server" Enabled="false" />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="cbYes" runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="No" ItemStyle-Width="60">
<ItemTemplate>
<asp:CheckBox ID="cbNo" runat="server" Enabled="false" />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox ID="cbNo" runat="server" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField ItemStyle-Width="150">
<ItemTemplate>
<asp:LinkButton ID="btnEdit" Text="Edit" runat="server" CommandName="Edit" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" />
<asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" />
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
DataTable dt = new DataTable();
dt.Columns.Add("UploadDocID", typeof(int));
dt.Columns.Add("FileDescr", typeof(string));
dt.Columns.Add("DocValid", typeof(string));
dt.Rows.Add(1, "Documnent File", "yes");
dt.Rows.Add(2, "HTML File", "yes");
dt.Rows.Add(3, "Word File", "yes");
dt.Rows.Add(4, "Excel File", "yes");
gvChecks.DataSource = dt;
gvChecks.DataBind();
}
protected void gvChecks_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
try
{
Label checkID = (Label)gvChecks.Rows[e.RowIndex].FindControl("lblUploadDocID");
CheckBox resYes = (CheckBox)gvChecks.Rows[e.RowIndex].FindControl("cbYes");
CheckBox resNo = (CheckBox)gvChecks.Rows[e.RowIndex].FindControl("cbNo");
string status = String.Empty;
if (resYes.Checked && resNo.Checked)
{
//appObj.myMessageBox("You can only choose one checkbox.");
}
else
{
if (resYes.Checked)
{
status = "TRUE";
}
else if (resNo.Checked)
{
status = "FALSE";
}
else
{
status = String.Empty;
}
}
gvChecks.EditIndex = -1;
BindGrid();
// updateApplicationCheckList(checkID.Text, status);
// bindApplicationChecks();
}
catch (Exception ex)
{
//myMessageBox(ex.Message);
}
}
protected void gvChecks_RowEditing(object sender, GridViewEditEventArgs e)
{
gvChecks.EditIndex = e.NewEditIndex;
BindGrid();
}
protected void gvChecks_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvChecks.EditIndex = -1;
BindGrid();
}