locked
LinkButton in Gridview RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I have below code but when i click on Link Button nothing is happening

    <asp:TemplateField HeaderText="Action">
                            <ItemTemplate>
                                <asp:linkbutton id="btnEdit"  ToolTip="Update Record" OnClick="lnkEdit_Click"
                                    runat="server" CssClass="clslnkbutton"/> 
    
    
                            </ItemTemplate>


    protected void lnkEdit_Click(object sender, EventArgs e)
    {

    }

    Thanks

    Tuesday, August 14, 2018 3:30 PM

Answers

  • User475983607 posted

    JagjitSingh

    Yes . Why so . When i commented required field validator then it is posting

    I believe the problem is self explanatory.  txtDescription is required but a value was not entered.

    Maybe you need validation groups?

    https://msdn.microsoft.com/en-us/library/ms227424.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 14, 2018 4:42 PM

All replies

  • User475983607 posted

    The common approach is using add, edit, and delete command buttons.

    https://www.aspsnippets.com/Articles/GridView-CRUD-Select-Insert-Edit-Update-Delete-using-Single-Stored-Procedure-in-ASPNet.aspx

    If the the page is not posting at all then you might have validation stopping the post.  Please take a moment to debug your code using dev tools to verify what's happening.

    Tuesday, August 14, 2018 4:10 PM
  • User-1499457942 posted

    Hi

      Yes . Why so . When i commented required field validator then it is posting

    <div class="form-group">
                                <asp:Label ID="lblCode" runat="server" CssClass="col-sm-4 control-label" Text="Code"></asp:Label>
                                <div class="col-sm-5">
                                    <asp:TextBox ID="txtCode" CssClass="form-control" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="rfv1" CssClass="text-danger" runat="server" ErrorMessage="This field is Required !" ControlToValidate="txtCode"></asp:RequiredFieldValidator>
                                </div>
                            </div>
                            <div class="form-group">
                                <asp:Label ID="lblDescription" runat="server" CssClass="col-sm-4 control-label" Text="Description"></asp:Label>
                                <div class="col-sm-8">
                                    <asp:TextBox ID="txtDescription"  CssClass="form-control" runat="server"></asp:TextBox>
                                    <%--<asp:RequiredFieldValidator ID="rfv2" CssClass="text-danger" runat="server" ErrorMessage="This field is Required !" ControlToValidate="txtDescription"></asp:RequiredFieldValidator>--%>
                                </div>
                            </div>

    Thanks

    Tuesday, August 14, 2018 4:28 PM
  • User475983607 posted

    JagjitSingh

    Yes . Why so . When i commented required field validator then it is posting

    I believe the problem is self explanatory.  txtDescription is required but a value was not entered.

    Maybe you need validation groups?

    https://msdn.microsoft.com/en-us/library/ms227424.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 14, 2018 4:42 PM