468,315 Members | 1,422 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

Why do labels have .DataBind ?

Roy
This may seem silly, but I'm just curious...

I've noticed that in the code-behind, asp:Label has the .DataBind
property yet has NO corresponding .DataSource property? Am I missing
something? How can you databind something that has no datasource?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Mar 7 '06 #1
2 923
It's inherited from the Control class.

HTH,
Darren Kopp
http://blog.secudocs.com/

Mar 7 '06 #2
You don't have to have DataSource in order to databind. All you need is to
use a databind expression for any of the control's properties. Example:

<asp:label ... Text='<%# CurrentDateString %>' ...

where CurrentDateString is a property you are binding your Text property to.
To get Text actually populated, you need to call the DataBind method.

Eliyahu

"Roy" <SP*******@gmail.com> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
This may seem silly, but I'm just curious...

I've noticed that in the code-behind, asp:Label has the .DataBind
property yet has NO corresponding .DataSource property? Am I missing
something? How can you databind something that has no datasource?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***

Mar 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by autofill | last post: by
2 posts views Thread by DBQueen | last post: by
6 posts views Thread by DebbieG | last post: by
3 posts views Thread by Grim Reaper | last post: by
3 posts views Thread by Grim Reaper | last post: by
3 posts views Thread by Marty McDonald | last post: by
2 posts views Thread by Steve Hershoff | last post: by
reply views Thread by xikom01 | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.