Asp.net ListView中的Repeater:如何绑定命令并调用它?

Asp.net ListView中的Repeater:如何绑定命令并调用它?,asp.net,listview,Asp.net,Listview,场景:我在ListView中有一个中继器。 在中继器内,我有一个链接按钮;这就是语法 <asp:LinkButton runat="server" ID="lnkRemoveComment" Text="Delete" Visible='<%# CheckVisibility() %>' CommandName="DeleteComment" CommandArgument='<%# Eval("id")%>'> </asp:LinkButton>

场景:我在ListView中有一个中继器。 在中继器内,我有一个链接按钮;这就是语法

<asp:LinkButton runat="server" ID="lnkRemoveComment" Text="Delete" Visible='<%# CheckVisibility() %>' CommandName="DeleteComment" CommandArgument='<%# Eval("id")%>'> </asp:LinkButton>

在服务器端代码中,我不知道调用以下代码的语法:

  • 删除注释
  • 检查可见性
我不知道,因为repeater嵌套在ListView中。 在ListView ItemCommand中插入代码不起作用

谢谢

示例:

.aspx
------------------ 
<asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
        <asp:LinkButton ID="LinkButton1" runat="server" OnCommand="LinkButton1_Command" CommandName="MyUpdate" CommandArgument='<%# Eval("erid") %>'>LinkButton</asp:LinkButton>
    </ItemTemplate>
</asp:Repeater>


.cs
------------------
protected void LinkButton1_Command(object sender, CommandEventArgs e)
{
    if (e.CommandName == "MyUpdate"){
        //e.CommandArgument --> contain the erid value
        //Do something
    }
}
.aspx
------------------ 
链接按钮
.cs
------------------
受保护的void LinkButton1_命令(对象发送方,CommandEventArgs e)
{
如果(e.CommandName==“MyUpdate”){
//e、 CommandArgument-->包含erid值
//做点什么
}
}