【问题标题】:Gridview buttonfield works LinkButton doesn'tGridview 按钮域有效 LinkBut​​ton 无效
【发布时间】:2011-02-05 07:00:33
【问题描述】:

我已经与这个问题作斗争了好几个小时了,真的需要一些帮助:-)

这是网格

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

【问题讨论】:

    标签: asp.net gridview linq-to-sql data-binding sitecore


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 没有你的建议 :(
      猜你喜欢
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多