Help requirerd in Data Binding function


I am learning ASP.NET.
I have a textbox (TextBox1) and a label (Label1) on the page, and I want to get the value of TextBox1 in Label1, via the Page.DataBind(); function. so
what I did is,


<asp:Label ID="Label1" runat="server" Text="<%# Label1Input.Text %>"></asp:Label>

and also wrote on page load Page.DataBind();.
But now http://localhost:4444/Test1/DataBindingTest.aspx is showing error [COLOR=#ff0000][B]CS0103: The name ‘Label1Input’ does not exist in the current context

[/B][/COLOR]Can someone help me in this?

What version of ASPNET are you using? If it’s 1.1 then you need to declare the textbox in the code-behind. If it’s 2.0 or greater, it sounds like your designer.cs page is corrupted: go in and add it by hand.

as you know control ids are dynamically generated as the page binds.
which means you cant do this <%# Label1Input.Text %> Just like your error says there is no control with id Label1Input.

easiest is to bind it on code behind.
for example Label1.Text=Label1Input.Text;

another approach is declaring a protected TextBox variable with Label1Input reference to it.
protected TextBox txt=Label1Input;
and now you could do this
<asp:Label ID=“Label1” runat=“server” Text=“<%# txt.Text %>”></asp:Label>