Monday, December 18, 2023

Gridview ASP.NET Linkbutton click event

aspx page

 <asp:TemplateField HeaderText="Select" Visible="true" >

                                    <ItemTemplate>

                                        <asp:LinkButton ID="lnkgrdDraftPreliminaryEnquirySelect" runat="server" CssClass="btn btn-danger"  ToolTip="Select" CommandName="Select" Text="Select" CausesValidation="false" CommandArgument='<%# Eval("preliminaryenquiryid") + ";"+ Eval("fileid")%>' OnClick="lnkgrdDraftPreliminaryEnquirySelect_Click" > </asp:LinkButton>

                                        <%--<asp:LinkButton ID="lnkgrdDraftPreliminaryEnquiryDelete" runat="server" CssClass="btn btn-danger"  ToolTip="delete" CausesValidation="false" CommandName="delete" >Delete</asp:LinkButton>--%>

                                    </ItemTemplate>

                                </asp:TemplateField>


aspx.cs page

 protected void lnkgrdDraftPreliminaryEnquirySelect_Click(object sender, EventArgs e)

        {


            foreach (GridViewRow row in grdDraftPreliminaryEnquiry.Rows)

            {

                LinkButton lnkgrdDraftPreliminaryEnquirySelect = (LinkButton)row.FindControl("lnkgrdDraftPreliminaryEnquirySelect");

                if (lnkgrdDraftPreliminaryEnquirySelect != null)

                {



                    int preEmqId = Convert.ToInt32(grdDraftPreliminaryEnquiry.DataKeys[row.RowIndex].Value);


                    PreliminaryEnquiryId = preEmqId;

                    lnkgrdDraftPreliminaryEnquirySelect.PostBackUrl = "PreliminaryEnquiryMigration.aspx?ReferenceId=" + PreliminaryEnquiryId + "&ReferenceType=" + CryptologyFunctions.Encrypt(Convert.ToInt64(EnumLookup.ReferenceType.PreliminaryEnquiry).ToString()) + "&PreliminaryEnquiryId=" + PreliminaryEnquiryId + " &Finalized=" + CryptologyFunctions.Encrypt("false") + "&ViewMode=false)";





                }

            }

        }

No comments:

Post a Comment