<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>
我的问题是:如何从文本框中获取文本,而btn拒绝单击操作?
protected void btnReject_Click(object sender, EventArgs e)
{
LinkButton btnReject = (LinkButton)sender;
// how to get tbReason.Text from this item?
}
此致
编辑:
问题解决了! 我们只需要添加Page_Load代码以防止重新加载listview并清除文本框:)
http://forums.asp.net/t/1712482.aspx/1
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lvAttachments.DataSource = tAttachmentBO.getAttachmentsToAccept();
lvAttachments.DataBind();
}
}
答案 0 :(得分:0)
这样的事情应该有效
我在ipad上为任何错误道歉
TextBox txt = (TextBox)btnReject.Parent.FindControl("tbReason")