PC Review


Reply
Thread Tools Rate Thread

Assigning 2 Databinding Expressions To The Same Property

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      18th Aug 2005
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.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Scott M.
Guest
Posts: n/a
 
      18th Aug 2005
text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname") %>,<%#
DataBinder.Eval(Container,"DataItem.membernames.fname") %>'




"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>



 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      18th Aug 2005
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.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Scott M." <s-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname") %>,<%#
> DataBinder.Eval(Container,"DataItem.membernames.fname") %>'
>
>
>
>
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>

>
>



 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      19th Aug 2005
Ok, try this then:

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



"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>
> "Scott M." <s-(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname") %>,<%#
>> DataBinder.Eval(Container,"DataItem.membernames.fname") %>'
>>
>>
>>
>>
>> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>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.
>>> --
>>> Nathan Sokalski
>>> (E-Mail Removed)
>>> http://www.nathansokalski.com/
>>>

>>
>>

>
>



 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      19th Aug 2005
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.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Scott M." <s-(E-Mail Removed)> wrote in message
news:uR2%(E-Mail Removed)...
> Ok, try this then:
>
> text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname"), %><%#
> DataBinder.Eval(Container,"DataItem.membernames.fname") %>'
>
>
>
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>
>> "Scott M." <s-(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> text='<%# DataBinder.Eval(Container,"DataItem.membernames.lname") %>,<%#
>>> DataBinder.Eval(Container,"DataItem.membernames.fname") %>'
>>>
>>>
>>>
>>>
>>> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>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.
>>>> --
>>>> Nathan Sokalski
>>>> (E-Mail Removed)
>>>> http://www.nathansokalski.com/
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs Microsoft ASP .NET 0 26th Sep 2007 12:54 AM
Assigning 2 Databinding Expressions To The Same Property Nathan Sokalski Microsoft ADO .NET 4 19th Aug 2005 03:10 AM
Assigning 2 Databinding Expressions To The Same Property Nathan Sokalski Microsoft ASP .NET 4 19th Aug 2005 03:10 AM
Databinding Expressions? Chike J. Okor Microsoft Dot NET 1 8th Oct 2003 09:09 AM
Databinding Expressions? Chike J. Okor Microsoft Dot NET Framework Forms 1 8th Oct 2003 09:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:57 PM.