I have a gridview that is populated with a datatable and has an item template with a checkbox in it. Even when the checkbox is checked, the cs code says checked=false.
Asp:
<asp:GridView ID="gvListOfPages" runat="server" AutoGenerateColumns="false" ShowHeader="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkPages" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="PageName" />
</Columns>
</asp:GridView>
C#:
foreach (GridViewRow row in gvListOfPages.Rows)
{
System.Web.UI.WebControls.CheckBox chk = (System.Web.UI.WebControls.CheckBox)row.Cells[0].FindControl("chkPages");
if (chk != null && chk.Checked)
{
int arrayIndex = Convert.ToInt32(chk.ID.Substring(chk.ID.Length - 1, chk.ID.Length));
}
}
Aucun commentaire:
Enregistrer un commentaire