May 2003 - Posts

Just helped out a guy that had ran into some problems with returning the value of the Text property of a label that was nested inside a DataList control.
He tried binding the value of it like this:

<asp:label id="myLabel" runat="server">Value: <%# DataBinder.Eval(Container.DataItem, "Value") %></asp:label>

This caused the Text property to return an empty string. Also when he removed <%# DataBinder.Eval(Container.DataItem, "Value") %> the property returned Value:

I suggested to him that he could place the entire inline contents of the Label control inside a text attribute in the label control, ending up with something like this:

<asp:label id="myLabel" runat="server" text='Value: <%# DataBinder.Eval(Container.DataItem, "Value") %' />

This solved his problem! I cannot truthfully say I understand why this solved his issue - perhaps it's a problem with event bubbling? Does any feel like commenting on this?

Just finished the website for Steve Smith's (along with Rob Howard and the ASP Alliance) upcoming book: ASP.NET Developer's Cookbook.

I'll update later with an URL, once I know that I'm allowed to post it =)

Also, as a side-note, I've promised myself that I'm gonna have to pick up my blogging! I have really been slacking off the blogging for the last months.

More Posts