为什么服务器端变量未绑定到.aspx文本框? [英] Why the server side variable is not getting bound to the .aspx textbox?

查看:34
本文介绍了为什么服务器端变量未绑定到.aspx文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    Public Class frmFMECA
    Inherits System.Web.UI.Page

    Public LastFailureDate As String

并在.aspx中像这样使用它

and using it like this in .aspx

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

,但是在文本框中,除了<%= this.LastFailureDate%>之外,它什么都没有显示.

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

推荐答案

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

You need to use a DataBinding Expression.

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

如果TextBox不在GridView,Repeater等内部,则需要在 Page_Load

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();
}

这篇关于为什么服务器端变量未绑定到.aspx文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆