簡體   English   中英

CommandArgument返回null

[英]CommandArgument is returning null

我有一個按鈕,我想用它生成一個軟刪除。 將OnCommand與Eval CommandArgument一起使用。

  <asp:Button ID="Button2" ValidationGroup="Delete" runat="server" Text="Delete" OnCommand="Button2_Command" 
            CommandArgument=<%# Eval("Product.Id") %> />

但是CommandArgument始終在后面的方法中返回null。

protected void Button2_Command(object sender, CommandEventArgs e)
    {
        var Id = e.CommandArgument.ToString();

        TransactionCode.DeletePurchase();
    }

獲取ID的表是.dll DataContext的一部分。 它適用於所有內容,但在這種情況下,它始終使我返回null。 我在.dll中也有一個類,其中包含DeletePurchase()方法。 我應該在課程中添加一些屬性或內容嗎? 謝謝!

命令參數值應在單引號內:

CommandArgument='<%# Eval("Product.Id") %>'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM