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="PG ridView_Se lectedInde xChanged"
OnDataBound="PGridView_Dat aBound"
OnRowCommand="PGridView_Ro wCommand"
OnRowDeleting="PGridView_R owDeleting ">
<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 :LinkButto n>
</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.
<asp:GridView ID="PGridView" runat="server"
... ...
OnRowDataBound="PGridView_
OnSelectedIndexChanged="PG
OnDataBound="PGridView_Dat
OnRowCommand="PGridView_Ro
OnRowDeleting="PGridView_R
<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
</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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER