1

我已经与这个问题作斗争了好几个小时,并且真的可以使用一些帮助:-)

这是网格

<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>    

单击按钮字段可以很好地删除记录。单击链接按钮不起作用。我收到回发,网格显示为空,并且没有删除任何记录。似乎是一个空的数据绑定。我试图为 LinkBut​​ton 创建一个自定义 OnClick、OnCommand 事件,但都没有被触发。OnRowCommand 也不会被触发。

我不在代码隐藏中手动 DataBind。

4

2 回答 2

1

问题不在于 Asp.net,而在于 Sitecore(A CMS),这里描述了简单的解决方案,http://www.cassidy.dk/blog/sitecore/2009/01/typesthatshouldnotbeexpanded.html

我觉得 Sitecore 偷走了我生命中的几个小时,问题已经解决了,所以我很高兴 :-)

于 2010-04-08T08:24:05.560 回答
0

您的代码看起来不错,应该可以工作。确保您没有在其他地方使用 lnkBtnDelete Id。您是否同时存在 buttonField 和 TemplateField?如果删除按钮域会发生什么?

于 2010-04-07T14:21:27.410 回答