Concatenating two databinding expressions - how??

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!
 
S

sydney.luu

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

Flinky Wisty Pomm

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

Benjamin Strackany

Does

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

work?

Benjamin Strackany
www.developmentnow.com
 
S

sydney.luu

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
 

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,777
Messages
2,569,604
Members
45,218
Latest member
JolieDenha

Latest Threads

Top