2 databinds in 1 parameter

  • Thread starter Thread starter Mike Johnson
  • Start date Start date
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
 
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
 
Back
Top