为什么服务器端变量没有绑定到.aspx文本框?

问题描述 投票:0回答:1
    Public Class frmFMECA
    Inherits System.Web.UI.Page

    Public LastFailureDate As String

并在.aspx中使用它

 <asp:TextBox ID="txtLastFailureDate_GR" Text="<%= this.LastFailureDate %>" runat="server"></asp:TextBox>

但它没有在文本框中显示除<%= this.LastFailureDate%>之外的任何内容。

asp.net vb.net public
1个回答
1
投票

您需要使用DataBinding表达式。

Text='<%# this.LastFailureDate %>'

如果TextBox不在GridView,Repeater等内,你需要在DataBind()中手动调用Page_Load

protected void Page_Load(object sender, EventArgs e)
{
    DataBind();
}
© www.soinside.com 2019 - 2024. All rights reserved.