转发器控件中的按钮单击事件以在 asp.net c# 中显示同一转发器中的数据

button click event in repeater control to show data in same repeater in asp.net c#

我在中继器内有一个按钮,用户应该可以看到其上的点击文本框,但我有一个按钮列表,点击特定按钮文本框应该仅为该按钮专门打开,

目前,当我单击按钮时,所有文本框都对用户可见。

这是代码....

    <asp:Repeater ID="rpt">
        <div align="right" id="reply">
            <asp:LinkButton ID="lnkbtnreply" OnClick="lnkbtnreply_Click" Text="Reply"></asp:LinkButton>
        </div>

        <asp:TextBox ID=""  placeholder="Enter Your Reply Here" Visible="false">
      </asp:TextBox>
   </asp:Repeater>

隐藏代码:

protected void lnkbtnreply_Click(object sender, EventArgs e) 
{ 
       foreach (RepeaterItem item in rptcomment.Items) 
       {
             Panel replypic = (Panel)item.FindControl("replypic");
             Panel replywrite = (Panel)item.FindControl("replywrite");
             replypic.Visible = true; replywrite.Visible = true;
       }
}

我找到了答案。如果你们还在寻找它,请看看:

下面是代码:

protected void rptcomment_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        Panel replypic = (Panel)e.Item.FindControl("replypic");
        Panel replywrite = (Panel)e.Item.FindControl("replywrite");
        if (e.CommandName == "img_Click") // check command is cmd_delete
        {
            // get you required value
            string CustomerID = (e.CommandArgument).ToString();
            replypic.Visible = true;
            replywrite.Visible = true;
        }
    }
}