Link to home
Start Free TrialLog in
Avatar of minglelinch
minglelinch

asked on

GridView row delete

I have defined Edit and Delete function for each row of a GridView as below -

<asp:GridView ID="PGridView" runat="server"  
          ... ...
          OnRowDataBound="PGridView_RowBound"
          OnSelectedIndexChanged="PGridView_SelectedIndexChanged"
          OnDataBound="PGridView_DataBound"
          OnRowCommand="PGridView_RowCommand"
          OnRowDeleting="PGridView_RowDeleting">
<asp:CommandField HeaderText="Edit" SelectText="Edit" ShowSelectButton="True" />
<asp:BoundField DataField="id" HeaderText="ID" />
... ...
<asp:TemplateField HeaderText="Delete">
          <ItemTemplate>
              <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("id") %>'
                CommandName="Delete" runat="server">Delete</asp:LinkButton>
          </ItemTemplate>
</asp:TemplateField>

My question is -
When I click the Delete LinkButton, it seems functions for both OnRowCommand and OnRowDeleting are executed. If I removed OnRowCommand, I got error. Should both functions always be present? If yes, what should usually be there in both functions? I just need to delete the row.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Kyle Abrahams, PMP
Kyle Abrahams, PMP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of minglelinch
minglelinch

ASKER

Happy new year. Thanks for the comments.