Label Text

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can the text property of the label web server control be formatted to
display more than one piece of text. For exmaple - I currently have the
below code. Currently this will just display the "ID" dataitem, but I want
it to say "The identification number is "ID"". How would I do this?

CODE...
Text='<%#DataBinder.Eval(Container.DataItem, "ID") %>'
 
Hi,

Try this?

<asp:Label runat="server" Text='<%#
[String].Concat("The identification number is ", DataBinder.Eval(Container,
"DataItem.ID"),".") %>'>
</asp:label>

Ken
MVP [ASP.NET]
 
Create your own custom control which inherits from
System.Web.UI.WebControls.Label.

Greetings

Daniel
 
Ken, Unfortunately not. Thanks for your help, though.

Ken Cox said:
Hi,

Try this?

<asp:Label runat="server" Text='<%#
[String].Concat("The identification number is ", DataBinder.Eval(Container,
"DataItem.ID"),".") %>'>
</asp:label>

Ken
MVP [ASP.NET]

MrMike said:
How can the text property of the label web server control be formatted to
display more than one piece of text. For exmaple - I currently have the
below code. Currently this will just display the "ID" dataitem, but I
want
it to say "The identification number is "ID"". How would I do this?

CODE...
Text='<%#DataBinder.Eval(Container.DataItem, "ID") %>'
 
Try this:

<asp:Label runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.ID", "The identification number is {0}.") %>'>


MrMike said:
Ken, Unfortunately not. Thanks for your help, though.

Ken Cox said:
Hi,

Try this?

<asp:Label runat="server" Text='<%#
[String].Concat("The identification number is ",
DataBinder.Eval(Container,
"DataItem.ID"),".") %>'>
</asp:label>

Ken
MVP [ASP.NET]

MrMike said:
How can the text property of the label web server control be formatted
to
display more than one piece of text. For exmaple - I currently have
the
below code. Currently this will just display the "ID" dataitem, but I
want
it to say "The identification number is "ID"". How would I do this?

CODE...
Text='<%#DataBinder.Eval(Container.DataItem, "ID") %>'
 
What doesn't work about it?

MrMike said:
Ken, Unfortunately not. Thanks for your help, though.

Ken Cox said:
Hi,

Try this?

<asp:Label runat="server" Text='<%#
[String].Concat("The identification number is ",
DataBinder.Eval(Container,
"DataItem.ID"),".") %>'>
</asp:label>

Ken
MVP [ASP.NET]

MrMike said:
How can the text property of the label web server control be formatted
to
display more than one piece of text. For exmaple - I currently have
the
below code. Currently this will just display the "ID" dataitem, but I
want
it to say "The identification number is "ID"". How would I do this?

CODE...
Text='<%#DataBinder.Eval(Container.DataItem, "ID") %>'
 
Hello Daniel,

You cannot be serious... Why would you need to derive a new custom control
just to set the Text property?
 
I have no idea if this will work.

<Text=' The identification number is <%#DataBinder.Eval(Container.DataItem,
"ID") %>'

bill
 
Back
Top