Concatenating two databinding expressions - how??

Discussion in 'ASP .Net' started by sydney.luu@gmail.com, Mar 28, 2006.

  1. Guest

    Hi,

    I want to assign two data values in the CommandArgument property of the
    LinkButton object.

    This works
    CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Arg1")%>'

    but this does not work
    CommandArgument='<%#DataBinder.Eval(Container.DataItem,
    "Arg1")%>,<%#DataBinder.Eval(Container.DataItem, "Arg2")%>'

    neither does this
    CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Arg1")%> &
    <%#DataBinder.Eval(Container.DataItem, "Arg2")%>'

    What's the syntax for this?

    Thanks!
    , Mar 28, 2006
    #1
    1. Advertising

  2. Guest

    I figured it out how to achieve this. I use

    CommandArgument='<%# SetUpArguments(DataBinder.Eval(Container.DataItem,
    "SystemBillToCode"), DataBinder.Eval(Container.DataItem,
    "NotifDate"))%>'

    Function SetUpArguments(arg1 as string, arg2 as string) As String
    SetUpArguments = arg1 & arg2
    End Function

    If you know the trick without a helper function, I'd still like to
    know.



    wrote:
    > Hi,
    >
    > I want to assign two data values in the CommandArgument property of the
    > LinkButton object.
    >
    > This works
    > CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Arg1")%>'
    >
    > but this does not work
    > CommandArgument='<%#DataBinder.Eval(Container.DataItem,
    > "Arg1")%>,<%#DataBinder.Eval(Container.DataItem, "Arg2")%>'
    >
    > neither does this
    > CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Arg1")%> &
    > <%#DataBinder.Eval(Container.DataItem, "Arg2")%>'
    >
    > What's the syntax for this?
    >
    > Thanks!
    , Mar 28, 2006
    #2
    1. Advertising

  3. If you want to databind with more complicated logic than "insert field
    a into slot b" you should look at the events that your templated
    control fires. Look at the OnItemDataBound event.

    You mentioned in another thread that you didn't want to hook into the
    event, any particular reason? The code will be a lot less hairy if you
    do things that way, even if it feels less intuitive.
    Flinky Wisty Pomm, Mar 28, 2006
    #3
  4. Does

    CommandArgument='<%# DataBinder.Eval(Container.DataItem, "SystemBillToCode")
    & DataBinder.Eval(Container.DataItem, "NotifDate"))%>'

    work?

    Benjamin Strackany
    www.developmentnow.com


    <> wrote in message
    news:...
    >I figured it out how to achieve this. I use
    >
    > CommandArgument='<%# SetUpArguments(DataBinder.Eval(Container.DataItem,
    > "SystemBillToCode"), DataBinder.Eval(Container.DataItem,
    > "NotifDate"))%>'
    >
    > Function SetUpArguments(arg1 as string, arg2 as string) As String
    > SetUpArguments = arg1 & arg2
    > End Function
    >
    > If you know the trick without a helper function, I'd still like to
    > know.
    >
    >
    >
    > wrote:
    >> Hi,
    >>
    >> I want to assign two data values in the CommandArgument property of the
    >> LinkButton object.
    >>
    >> This works
    >> CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Arg1")%>'
    >>
    >> but this does not work
    >> CommandArgument='<%#DataBinder.Eval(Container.DataItem,
    >> "Arg1")%>,<%#DataBinder.Eval(Container.DataItem, "Arg2")%>'
    >>
    >> neither does this
    >> CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Arg1")%> &
    >> <%#DataBinder.Eval(Container.DataItem, "Arg2")%>'
    >>
    >> What's the syntax for this?
    >>
    >> Thanks!

    >
    Benjamin Strackany, Mar 29, 2006
    #4
  5. Guest

    This did not work and after a careful examination "under the hood" of
    how Databinding works, I discovered ultimately the "DataBinder.Eval()
    get passed into a ConvertToString(). I believe this is the function it
    used when I looked the page at compiled time. That's how I came to the
    idea of setting up a helper/wrapper. Another easy option would be
    to have this done in Sqlserver.

    Someone asked why I didn't put this in my ItemDataBound event?
    Originally that's how I had it. I just didn't like the fact I had to
    search for my LinkButton webserver control
    and after I found it, then assign the value to the properties. Which
    is faster? Depends how you look at it and many other factors.

    Sydney


    Benjamin Strackany wrote:
    > Does
    >
    > CommandArgument='<%# DataBinder.Eval(Container.DataItem, "SystemBillToCode")
    > & DataBinder.Eval(Container.DataItem, "NotifDate"))%>'
    >
    > work?
    >
    > Benjamin Strackany
    > www.developmentnow.com
    >
    >
    > <> wrote in message
    > news:...
    > >I figured it out how to achieve this. I use
    > >
    > > CommandArgument='<%# SetUpArguments(DataBinder.Eval(Container.DataItem,
    > > "SystemBillToCode"), DataBinder.Eval(Container.DataItem,
    > > "NotifDate"))%>'
    > >
    > > Function SetUpArguments(arg1 as string, arg2 as string) As String
    > > SetUpArguments = arg1 & arg2
    > > End Function
    > >
    > > If you know the trick without a helper function, I'd still like to
    > > know.
    > >
    > >
    > >
    > > wrote:
    > >> Hi,
    > >>
    > >> I want to assign two data values in the CommandArgument property of the
    > >> LinkButton object.
    > >>
    > >> This works
    > >> CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Arg1")%>'
    > >>
    > >> but this does not work
    > >> CommandArgument='<%#DataBinder.Eval(Container.DataItem,
    > >> "Arg1")%>,<%#DataBinder.Eval(Container.DataItem, "Arg2")%>'
    > >>
    > >> neither does this
    > >> CommandArgument='<%#DataBinder.Eval(Container.DataItem, "Arg1")%> &
    > >> <%#DataBinder.Eval(Container.DataItem, "Arg2")%>'
    > >>
    > >> What's the syntax for this?
    > >>
    > >> Thanks!

    > >
    , Mar 29, 2006
    #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. Replies:
    3
    Views:
    374
    kwikius
    Mar 2, 2007
  2. Rusty Hill
    Replies:
    0
    Views:
    359
    Rusty Hill
    Apr 30, 2007
  3. jobs
    Replies:
    0
    Views:
    1,617
  4. Tamer Ibrahim
    Replies:
    1
    Views:
    577
    JIGNESH
    Jan 17, 2008
  5. Earl Teigrob
    Replies:
    1
    Views:
    401
    Shravan
    Mar 1, 2004
Loading...

Share This Page