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

时间:2019-05-01 08:29:36

标签: asp.net vb.net public

    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%>外,它什么也没有显示。

1 个答案:

答案 0 :(得分:1)

您需要使用数据绑定表达式。

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

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

protected void Page_Load(object sender, EventArgs e)
{
    DataBind();
}
相关问题