2 databinds in 1 parameter

M

Mike Johnson

I am trying to create a panel control with a tooltip that contains dynamic
information in it. So, when the user hovers over the panel, it shows them
some information on the record. I can get it to work fine with 1 database
field with this statement.

<asp:panel id="pnlInfo" runat="server" ToolTip='<%#
DataBinder.Eval(container.DataItem, "id", "ID={0}" %>'></asp:panel>

I'd like to add more fields in the tooltip but get an error when I try to do
this....

<asp:panel id="pnlInfo" runat="server" ToolTip='<%#
DataBinder.Eval(container.DataItem, "id", "ID={0}" %> <%#
DataBinder.Eval(container.DataItem, "enteredby", "Entered by={0}"
%>'></asp:panel>

Error I get is Overload resolution failed because no accessible 'ToString'
accepts this number of arguments.

Is this the correct way to do this?

Thanks
 
G

Guest

Mike, you can concatenate using the ampersand (vb) within the one databinding expression like this

Tooltip = '<%# EvalResultingInString1 & EvalResultingInString2, etc. %>

If you want to do fancier string formatting outside of this, or maybe to keep it cleaner, you can also from within the databinding expression call a public function, e.g

<%# FormatToolTip(field1, field2, field3, etc.) %

....where FormatToolTip is a method on your class that takes the parms and returns a single string

Bil

----- Mike Johnson wrote: ----

I am trying to create a panel control with a tooltip that contains dynami
information in it. So, when the user hovers over the panel, it shows the
some information on the record. I can get it to work fine with 1 databas
field with this statement

<asp:panel id="pnlInfo" runat="server" ToolTip='<%
DataBinder.Eval(container.DataItem, "id", "ID={0}" %>'></asp:panel

I'd like to add more fields in the tooltip but get an error when I try to d
this...

<asp:panel id="pnlInfo" runat="server" ToolTip='<%
DataBinder.Eval(container.DataItem, "id", "ID={0}" %><%
DataBinder.Eval(container.DataItem, "enteredby", "Entered by={0}
%>'></asp:panel

Error I get is Overload resolution failed because no accessible 'ToString
accepts this number of arguments

Is this the correct way to do this

Thank
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top