Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenating Data Items 1

Status
Not open for further replies.

spage7777

Programmer
Mar 19, 2007
10
US
Greetings,

I have the following code in an .aspx web page and am receiving the error: "Compiler Error Message: CS1026: ) expected". I can't see where it is expecting an extra parenthesis. The line of code it fails on is the following:

<asp:Label id=lblName runat="server" Text='<%# DataBinder.Eval(Container,"DataItem.FirstName") + " " + DataBinder.Eval(Container,"DataItem.LastName"); %>'>
</asp:Label>

I'm simply trying to concatenate the first name and last name in a data list. Any ideas as to what I am doing wrong?

Thanks in advance!
 
should do the trick.
Code:
<asp:Label id=lblName runat="server" Text='<%# string.Format("{0} {1}", Eval("FirstName"), Eval("LastName")) %>' />

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top