How to bind an HTML Label to sqldatareader

334 views Asked by At

I am trying to bind a label to a datareader. With an input type="text" I am able to do something like this

MyName.Value = reader["MyName"].ToString();

-

 <label id="lblMyName" runat="server"></label>

I cant figure out how to bind this in the code behind as I dont see a lblMyName.Value or .Text

1

There are 1 answers

0
Prash On

Use lblMyName.InnerText

But, any reason why you don't want to use asp.net Label control.

<asp:Label id="lblMyName" runat="server"></asp:Label>

With this lblMyName.Text works.