zintech
asked on
ASP.NET gridview delete linkbutton
I have an ASP.NET GridView that has a LinkButton field for a Delete option on the GridView for each row. However when I click the Delete LinkButton on the Gridview, it does not do anything. I have a DELETE command specified on the DataSource that is associated with the Gridview. I just can't figure out why the Delete command will not fire. Here is the GridView's code:
<asp:GridView ID="VersionGridView" runat="server" AllowPaging="True"
AutoGenerateColumns="False " BackColor="White" BorderColor="#E7E7FF"
BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="Id"
DataSourceID="VersionDataS ource" EmptyDataText="No versions."
onrowcreated="VersionGridV iew_RowCre ated"
OnRowDeleting="VersionGrid View_RowDe leting" PageSize="5"
style="margin-left: 18px" Width="567px"
onrowdatabound="VersionGri dView_RowD ataBound" >
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButtonDelete" CommandName="Delete" Text="Delete" runat="server"></asp:LinkB utton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<AlternatingRowStyle BackColor="#F7F7F7" />
</asp:GridView>
<asp:GridView ID="VersionGridView" runat="server" AllowPaging="True"
AutoGenerateColumns="False
BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="Id"
DataSourceID="VersionDataS
onrowcreated="VersionGridV
OnRowDeleting="VersionGrid
style="margin-left: 18px" Width="567px"
onrowdatabound="VersionGri
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButtonDelete" CommandName="Delete" Text="Delete" runat="server"></asp:LinkB
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<AlternatingRowStyle BackColor="#F7F7F7" />
</asp:GridView>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.