Assigning 2 Databinding Expressions To The Same Property

N

Nathan Sokalski

I have two databinding expressions (the first & last names from a DB) that I
want to assign to the text property of a Label so that the result is
LASTNAME,FIRSTNAME. At the moment, I have the following which I know works
when I use it by itself:

text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname") %>'

What I need to do is somehow concatenate this databinding expression, a
comma, and another databinding expression for the first name (which looks
almost the same). How can I do this? Thanks.
 
S

Scott M.

text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname") %>,<%#
DataBinder.Eval(Container,"DataItem.membernames.fname") %>'
 
N

Nathan Sokalski

That was my original attempt, but it gives me an error when I try to use it.
Here is the error I recieve when trying to do it that way:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30037: Character is not valid.

Source Error:


Line 45: <asp:Label id="lblOrganization1" runat="server"
EnableViewState="False" Width="175px" text='<%#
DataBinder.Eval(Container,"DataItem.members.organization") %>'>
Line 46: </asp:Label>
Line 47: <asp:Label id="lblName1" runat="server"
EnableViewState="False" Width="175px" text='<%#
DataBinder.Eval(Container,"DataItem.membernames.lname") %>,<%#
DataBinder.Eval(Container,"DataItem.membernames.fname") %>'>
Line 48: </asp:Label>
Line 49: <asp:Label id="lblRegion1" runat="server"
EnableViewState="False" Width="125px" text='<%#
DataBinder.Eval(Container,"DataItem.pacounties.region") %>'>

Source File:
D:\Clients\12654\papresenters.org\papresenters.org\membersearch.aspx
Line: 47

If you want to see the "Detailed Compiler Output" or "Complete Compilation
Source" (they were too long to put in a newsgroup posting) let me know and I
will be happy to email them to you. Thank you for any help you can give.
 
S

Scott M.

Ok, try this then:

text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname"), %><%#
DataBinder.Eval(Container,"DataItem.membernames.fname") %>'
 
N

Nathan Sokalski

I tried that, I got the same result as before:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: BC30037: Character is not valid.

Source Error:



Line 45: <asp:Label id="lblOrganization1" runat="server"
EnableViewState="False" Width="175px" text='<%#
DataBinder.Eval(Container,"DataItem.members.organization") %>'>
Line 46: </asp:Label>
Line 47: <asp:Label id="lblName1" runat="server"
EnableViewState="False" Width="175px" text='<%#
DataBinder.Eval(Container,"DataItem.membernames.lname"), %><%#
DataBinder.Eval(Container,"DataItem.membernames.fname") %>'>
Line 48: </asp:Label>
Line 49: <asp:Label id="lblRegion1" runat="server"
EnableViewState="False" Width="125px" text='<%#
DataBinder.Eval(Container,"DataItem.pacounties.region") %>'>


Source File:
D:\Clients\12654\papresenters.org\papresenters.org\membersearch.aspx
Line: 47


I think, although I am not sure because I am not an expert on databinding,
that the two values need to be concatenated either somehow in the codebehind
file or using some kind of formatting technique. I have seen formatting
methods (not in databinding, but in other areas) where the format string
uses numbers to represent the different values in the same way that 0 is
often used in DataBinder.Eval's optional third parameter. I was wondering if
there was some way to do something similar to this (the only problem is that
I don't know of a way to create more than one value). Let me know if you
find any more ideas. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top