0

Rank is my server side variable.

I am trying this

<asp:TextBox ID="sds" runat="server" Text="<%# Eval(Rank) %>"></asp:TextBox>

But there comes nothing in text box, however when I write the same on response stream, it gives me result.

<%= Rank %>

I tried without Eval also.

<asp:TextBox ID="sds" runat="server" Text="<%# Rank %>">

Why it's coming null when assigned to textbox?

Thanks.

Imad
  • 7,126
  • 12
  • 55
  • 112

2 Answers2

0

Try like this:

Text='<%# Bind("rank") %>'

For example:

<asp:TextBox ID="sds" runat="server" Text='<%# Bind("rank") %>'  ></asp:TextBox>
0

Have you tried adding

this.DataBind();

to your page load? Referenced from article Get variable value from code behind and use in aspx page control

The other answers above are also acceptable but you need to choose your method or preference and the context/method your data is being generated and referenced into (Controls, plain HTML, etc...).

HTH

Dave

Community
  • 1
  • 1
Dave
  • 740
  • 1
  • 6
  • 17