Setting Visible with Databinder.Eval

B

Björn Jansson

Hi,
I hope this is the right forum for my question.

I have a Repeater control in which I have two panels. Only one panel should
be visible at a time. I want to set which one dynamically, so I tried the
following:

<asp:panel id="pnlDeliveryInfo" runat="server" Visible='<%#
IsNotNull((object)DataBinder.Eval(Container.DataItem, "Delivery")).ToString()
%>'>

Where IsNotNull is a function taking an object an returning a string (I also
tried to return a bool).

When I try to run i get the following compilation error:
"CS0030: Cannot convert type 'string' to 'bool'"


Anyone has any idea what I may be doing wrong?
Thanks!

Regards,
Björn Jansson
 
B

Björn Jansson

I just needed to sleep to find out the answer myself :)
There shouldn't be any ' characters and the function should return a bool.

So the right way to do it was:
<asp:panel id="pnlDeliveryInfo" runat="server" Visible=<%#
IsNotNull((object)DataBinder.Eval(Container.DataItem, "Delivery"))
%>>

Where IsNotNull() returns a bool

Hope this helps someone!

//Björn
 

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,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top