why my modal doesn't fire rowcommand and maintain checkbox state after PAGINATION.

It works fine on first page but after changing page it disappears upon CHECKBOX checking and doesn't maintain state. why ?

  <asp:HiddenField ID="hdnField1" runat="server" />
                <asp:ModalPopupExtender ID="mdlLastHearingDates" BackgroundCssClass="modalBackground" runat="server" TargetControlID="hdnField1"
                    PopupControlID="pnlLastHearingDates">
                </asp:ModalPopupExtender>

  <asp:Panel ID="pnlLastHearingDates" CssClass="modalPopup" style="min-height: 329px" runat="server" HorizontalAlign="Center" Visible="true">
                    <div class="panel-header bg-success" style="height: 41px; padding-top: 1px; padding-left: 5px;">
                        <h4>Upcoming Hearings</h4>

                        <asp:Button ID="btnCloseModal" Text="X" runat="server" CausesValidation="false" OnClick="btnCloseModal_Click"
                            CssClass="btn btn-primary pull-right btn-sm" Style="margin-top: -37PX; margin-right: 4px; color: whitesmoke; background-color: tomato" />
                    </div>
                    <asp:GridView runat="server" ID="grdViewLastHearingDates" Width="100%" AllowPaging="true" PageSize="3" OnPageIndexChanging="grdViewLastHearingDates_PageIndexChanging"
                        OnRowCommand="grdViewLastHearingDates_RowCommand" PagerStyle-BackColor="#99CC99" HeaderStyle-BackColor="#99CC99" DataKeyNames="pk_CaseHearings_ID" OnRowDataBound="grdViewLastHearingDates_RowDataBound"
                        PagerStyle-Font-Size="12.5px" PagerStyle-ForeColor="Black" PagerStyle-HorizontalAlign="Center" AutoGenerateColumns="false" OnRowEditing="grdViewLastHearingDates_RowEditing"
                        CssClass="table table-condensed table-bordered table-striped table-responsive">
                        <Columns>
                            <asp:BoundField DataField="pk_CaseHearings_ID" HeaderText="S.No" />
                            <asp:BoundField DataField="CaseNo" HeaderText="Case No" />
                            <asp:BoundField DataField="HearingDate" HeaderText="Hearing Date" />
                            <asp:BoundField DataField="DaysRemaining" HeaderText="Days Remaining" />
                            <asp:TemplateField HeaderText="Conveyed ?">
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkBoxIsConveyed" runat="server" AutoPostBack="true" Checked='<%# Convert.ToBoolean(Eval("IsConveyed")) %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Remarks">
                                <ItemTemplate>
                                    <asp:TextBox ID="txtBoxConvenienceRemarks" TextMode="MultiLine" Text='<%#Eval("ConvenienceRemarks") %>' CssClass="form-control white" runat="server"></asp:TextBox>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <%--<asp:ButtonField CommandName="cmdSelect" HeaderText="View Details" ImageUrl="~/assets/global/images/shopping/monitor.png"
                                ButtonType="Image" ControlStyle-Width="25px" ControlStyle-Height="25px" />--%>
                        </Columns>
                    </asp:GridView>
                </asp:Panel>

and yes it is inside the update panel.

Code behind:

protected void grdViewLastHearingDates_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            int index = MngOtherFunctions.CalculatedIndex(sender as GridView, Convert.ToInt32(e.CommandArgument));

            int CaseHearingID = Convert.ToInt32(grdViewLastHearingDates.DataKeys[index].Value);
            short UserID = Convert.ToInt16(Session["UserID"]);

            if (e.CommandName == "cmdSelect")
            {

                string CaseNo = grdViewLastHearingDates.Rows[index].Cells[1].Text;
                //grdviewCaseHearingsDetails.DataSource = MngCaseHearings.SelectCaseANDHearingDetailsByCaseNo(CaseNo, UserID);
                txtSearch.Text = CaseNo;

                UpdateIsConveyed();
                mdlLastHearingDates.Hide();
                Multiview1.ActiveViewIndex = 1;
                //grdviewCaseHearingsDetails.Focus();

            }

        }
        catch (Exception ex)
        {
            Response.Write(Convert.ToString(ex.Message));
        }

    }

and

protected void grdViewLastHearingDates_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdViewLastHearingDates.PageIndex = e.NewPageIndex;
        ShowLastHearingDates();
       // pnlLastHearingDates.Visible = true;
        mdlLastHearingDates.Show();

    }

Help please.

Related posts

Recent Viewed