1

Background: The problem I have with my code is the following. Upon the first click of a button the checkbox doesn't get the checked checkboxes, but on the second click just get all the checked checkboxes.

Here is the code:

ASPX

This button execute the process..

<asp:LinkButton ID="lbDeletePerman" runat="server" OnClick="lbDeletePerman_Click">Yes</asp:LinkButton>
<code><asp:UpdatePanel ID="GVUpdatePanel" runat="server" UpdateMode="Conditional">
        <ContentTemplate>

            <asp:GridView CssClass="da-table" ID="Gv_A" runat="server" DataKeyNames="ID,PatientName" AutoGenerateColumns="false" OnRowCommand="Gv_Appoint_RowCommand">
                <Columns>
                    <asp:TemplateField HeaderStyle-Font-Bold="true" HeaderText="Select">
                        <ItemTemplate>
                            <asp:CheckBox ID="CbE" runat="server" />
                            <asp:HiddenField ID="hID" Value='<%# Eval("IDENTIFICATION") %>' runat="server" />
                        </ItemTemplate>
                    </asp:TemplateField>

                    <asp:BoundField DataField=""Date" HeaderText="Date" HeaderStyle-Font-Bold="true" HeaderStyle-VerticalAlign="Middle" ItemStyle-VerticalAlign="Middle" />

                    <asp:BoundField DataField="Cat" HeaderText="Type" HeaderStyle-Font-Bold="true" HeaderStyle-VerticalAlign="Middle" ItemStyle-VerticalAlign="Middle" />
                    <asp:BoundField DataField="Deleted" HeaderText="Deleted" HeaderStyle-Font-Bold="true" HeaderStyle-VerticalAlign="Middle" ItemStyle-VerticalAlign="Middle" />
                </Columns>
            </asp:GridView>

        </ContentTemplate>
    </asp:UpdatePanel>

C#:

protected void lbDeletePerman_Click(object sender, EventArgs e)
{
    try
    {

        foreach (GridViewRow rowItem in Gv_Appoint.Rows)
        {
            CheckBox CboxElim = (CheckBox)(rowItem.Cells[0].FindControl("CbE")); 
            if (CboxElim.Checked)
            {
                LBLT.Text = "Hello"; // NO ENTERING HERE
            }

        } 
        GVUpdatePanel.Update();
    } catch (Exception er){}
}

Any help would be appreciated

1 Answer 1

0

lbDeletePerman needs to be inside UpdatePanel together with Gv_A.

Or use the AsyncPostBackTrigger

<asp:LinkButton ID="lbDeletePerman" runat="server" 
  OnClick="lbDeletePerman_Click">Yes</asp:LinkButton>

<asp:UpdatePanel ID="GVUpdatePanel" runat="server" UpdateMode="Conditional">
   <ContentTemplate>
      <Triggers>
        <asp:AsyncPostBackTrigger ControlID="lbDeletePerman" />
      </Triggers>
      <asp:GridView>...</asp:GridView>
   </ContentTemplate>
</asp:UpdatePanel>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.