mardi 22 septembre 2015

CheckboxChanged event not firing in GridView on checkbox uncheck

I have a Checkbox in the grid view and I am having a OnCheckedChange event. This event is fired on Check and also if there are multiple rows in the Grid. But when there is only one row the OnCheckedChange event is fired on checking the checkbox but not on Unchecking the checkbox. I am trying to resolve this issue. But so far nothing good has happened. following is my code.

<asp:TemplateField HeaderStyle-CssClass="GridHeaderStyle" ItemStyle-CssClass="GridRowStyle" ItemStyle-HorizontalAlign="Center">
 <ItemTemplate>
            <asp:CheckBox ID="chkSelectEmployee" runat="server" key="chkEmployeeSrcItem" index='<%# DataBinder.Eval (Container, "RowIndex") %>' pair='<%# DataBinder.Eval (Container.DataItem, "ID") %>' AutoPostBack="true" OnCheckedChanged="chkSelectEmployee_CheckedChanged" />
 </ItemTemplate>
</asp:TemplateField>

protected void gvEmployeeSource_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        //Code Goes here
    }
}

protected void chkEmployeeSource_CheckedChanged(object sender, EventArgs e)
{
   //Code goes here
}




Aucun commentaire:

Enregistrer un commentaire