Solved label databinding static text

Posted on 2012-03-27
Last Modified: 2012-03-27

I have the following label

    <asp:Label ID="lblBedrooms" runat="server" Text='<%#Eval("Bedrooms") %>'></asp:Label>

which is fine as it displays what i want but I want static text which is bedroom but then after that i need another dynamic text called type

please help


Question by:R8VI
  • 2
LVL 38

Expert Comment

by:Tom Beck
ID: 37771485
Text='<%#Eval("Bedrooms") + " " + <%#Eval("Type")  %>'

Author Comment

ID: 37771526

I tried this

 <asp:Label ID="lblBedrooms" runat="server" Text='<%#Eval("Bedrooms") +"Bedroom"+ <%#Eval("PropertyType")  %>'></asp:Label>

and this does not work


LVL 13

Expert Comment

ID: 37771592
You could always use 3 labels:

<asp:Label ID="lblBedrooms" runat="server" Text='<%#Eval("Bedrooms") %>'></asp:Label>
<asp:Label ID="lbBedroom" runat="server">Bedroom</asp:Label>
<asp:Label ID="lblPropertyType" runat="server" Text='<%#Eval("PropertyType") %>'></asp:Label>

Open in new window

LVL 38

Accepted Solution

Tom Beck earned 500 total points
ID: 37771775
Sorry about that, this works (tested):

Text='<%# String.Format("{0} {1} {2}", Eval("Bedrooms"),"Bedroom", Eval("PropertyType")) %>'

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
defining NULL or 0 10 44
Iteration Help ( VB) 5 25
IEnumerable<T> to a List<T> 8 40
How to filter by key press ? 6 25
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question