views:

45

answers:

2

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.

A: 

Your code looks fine and should work. Make sure that you aren't using the lnkBtnDelete Id somewhere else. Do you have both the buttonField and the TemplateField present at the same time? What happens if you remove the buttonfield?

kgiannakakis
No luck with your suggestions :(
Karsten
A: 

The problem wasn't with Asp.net but with Sitecore (A CMS), the simple solution is described here, http://www.cassidy.dk/blog/sitecore/2009/01/typesthatshouldnotbeexpanded.html.

I feel like Sitecore has stolen several hours of my life, well the problem is solved, so I'm happy :-)

Karsten