Why the server side variable is not getting bound to the .aspx textbox?

∥☆過路亽.° 提交于 2020-01-06 04:31:33

问题


    Public Class frmFMECA
    Inherits System.Web.UI.Page

    Public LastFailureDate As String

and using it like this in .aspx

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

but it doesn't show that anything but <%= this.LastFailureDate %> inside the textbox.


回答1:


You need to use a DataBinding Expression.

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

And if the TextBox is not inside a GridView, Repeater etc you need to manually call DataBind() in the Page_Load

protected void Page_Load(object sender, EventArgs e)
{
    DataBind();
}


来源:https://stackoverflow.com/questions/55933546/why-the-server-side-variable-is-not-getting-bound-to-the-aspx-textbox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!