Gridview buttonfield works LinkButton doesn't
- by Karsten
I've been fighting this problem for many hours now and could really use some help :-)
This is the grid
<asp:GridView ID="annonceView" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="dataSourceAnnoncer">
<Columns>
<asp:BoundField DataField="Productname" HeaderText="Productname" />
<asp:buttonfield buttontype="Link" commandname="Delete" text="Delete"/>
<asp:TemplateField HeaderText="Administration">
<ItemTemplate>
<asp:LinkButton ID="lnkBtnDelete" runat="server" Text="Delete" CausesValidation="False" CommandName="Delete" OnClientClick="return confirm('Delete?')" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:LinqDataSource ID="dataSourceAnnoncer" runat="server" ContextTypeName="Namespcae.TheContext"
EnableDelete="True" TableName="Annoncer">
</asp:LinqDataSource>
Clicking the buttonfield deletes the record just fine. Clicking the LinkButton doesn't work. I get a postback and the grid is shown as empty and no record is deleted. Seems like an empty databinding.
I have tried to create a custom OnClick, OnCommand event for the LinkButton, but neither are fired. The OnRowCommand isn't fired either.
I don't manually DataBind in the codebehind.