0
            <asp:ListView runat="server" ID="lvAttachments" ItemPlaceholderID="ph" OnItemDataBound="lvAttachments_ItemDataBound">
                <LayoutTemplate>
                    <asp:PlaceHolder ID="ph" runat="server"></asp:PlaceHolder>
                </LayoutTemplate>
                <ItemTemplate>
                                <asp:LinkButton runat="server" ID="btnReject" OnClick="btnReject_Click"></asp:LinkButton>
                                <asp:TextBox runat="server" ID="tbReason" CssClass="textbox" TextMode="MultiLine"></asp:TextBox>
                </ItemTemplate>
            </asp:ListView>

我的问题是:如何从文本框中获取文本,而 btnReject 点击操作?

protected void btnReject_Click(object sender, EventArgs e)
{
    LinkButton btnReject = (LinkButton)sender;
    // how to get tbReason.Text from this item?

}

问候

编辑:

问题解决了!我们只需要添加 Page_Load 代码来防止重新加载列表视图和清除文本框:)

http://forums.asp.net/t/1712482.aspx/1

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        lvAttachments.DataSource = tAttachmentBO.getAttachmentsToAccept();
        lvAttachments.DataBind();
    } 
  }
4

1 回答 1

0

像这样的东西应该工作

我在 ipad 上,如有错误请见谅

TextBox txt = (TextBox)btnReject.Parent.FindControl("tbReason")
于 2013-04-14T15:34:30.150 回答