Concatenating two databinding expressions - how??

  • Thread starter Thread starter sydney.luu
  • Start date Start date
S

sydney.luu

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!
 
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.
 
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.
 
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
 
Back
Top