Assigning 2 Databinding Expressions To The Same Property

Discussion in 'ASP .Net' started by Nathan Sokalski, Aug 18, 2005.

  1. 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

    http://www.nathansokalski.com/
     
    Nathan Sokalski, Aug 18, 2005
    #1
    1. Advertising

  2. Nathan Sokalski

    Scott M. Guest

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




    "Nathan Sokalski" <> wrote in message
    news:...
    >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
    >
    > http://www.nathansokalski.com/
    >
     
    Scott M., Aug 18, 2005
    #2
    1. Advertising

  3. 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

    http://www.nathansokalski.com/

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

    >
    >
     
    Nathan Sokalski, Aug 18, 2005
    #3
  4. Nathan Sokalski

    Scott M. Guest

    Ok, try this then:

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



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

    >>
    >>

    >
    >
     
    Scott M., Aug 19, 2005
    #4
  5. 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

    http://www.nathansokalski.com/

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

    >>
    >>

    >
    >
     
    Nathan Sokalski, Aug 19, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nathan Sokalski
    Replies:
    1
    Views:
    3,603
    Karl Seguin
    Aug 19, 2005
  2. jobs
    Replies:
    0
    Views:
    1,630
  3. Nathan Sokalski

    Using Multiple Databinding Values In The Same Property

    Nathan Sokalski, Aug 19, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    150
    Karl Seguin
    Aug 19, 2005
  4. Patrick Maupin
    Replies:
    12
    Views:
    502
    Patrick Maupin
    Oct 29, 2011
  5. weston
    Replies:
    1
    Views:
    253
    Richard Cornford
    Sep 22, 2006
Loading...

Share This Page