I have a gridview that contains checkboxes. The problem I am having is that when I try to access my checkbox in my C# code it keeps returning a null value. Its almost as if C# does not recognise the ID value of the checkbox in the aspx.
My GridView
<dx:ASPxGridView ID="grvQualificationScheduleDetails" runat="server" KeyFieldName="ModuleEnrollmentId" SettingsPager-Mode="ShowAllRecords">
<Columns>
<dx:GridViewDataColumn FieldName="Academicyear" VisibleIndex="0" Caption="Year" />
<dx:GridViewDataColumn FieldName="ModuleName" VisibleIndex="1" Caption="Module Name" />
<dx:GridViewDataColumn FieldName="ScheduleName" VisibleIndex="2" Caption="Schedule Name" />
<dx:GridViewDataColumn FieldName="ScheduleGroupName" VisibleIndex="3" Caption="Group Name" />
<dx:GridViewDataColumn FieldName="Result" VisibleIndex="4" Caption="Status" />
<dx:GridViewDataColumn FieldName="ModuleEnrollmentId" VisibleIndex="5" Visible="false" Caption="ModuleEnrollmentId" />
<dx:GridViewDataColumn FieldName="" VisibleIndex="6">
<DataItemTemplate>
<dx:ASPxCheckBox ID="ChkSelected" OnCheckedChanged="ChkSelected_CheckedChanged" Checked='<%#((IsSelected((int)Eval("ModuleEnrollmentId"))==true))?false:true %>' AutoPostBack="true" runat="server"></dx:ASPxCheckBox>
</DataItemTemplate>
</dx:GridViewDataColumn>
</Columns>
</dx:ASPxGridView>
My C# method
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ASPxCheckBox chk = (ASPxCheckBox)grvQualificationScheduleDetails.FindControl("ChkSelected");
chk.Checked = false;
}
}
Aucun commentaire:
Enregistrer un commentaire