web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

EP Visible = Expression

(0) ShareShare
ReportReport
Posted on by 695

Hi,

 I'm trying to hide a user control on a webpartpage depending on a value in my dataset.  I'm using the following for the Visible property of my control:

Visible

='<%#(Eval("MyFieldName")="0" ? false:true)%>'

 I then save my control and no errors are generated, however when I run in in SharePoint I get (debug is on):

System.Web.HttpCompileException: c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\ep\MH_EPVPPaymInfo.ascx(11): error CS0029: Cannot implicitly convert type 'string' to 'bool'

Your help is greatly appreciated.

 

 

 

 

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    Re: EP Visible = Expression

    Hi,

    Use == rather than =. = is for affectation causing ultimately the string "0" being used as the "boolean" value to be tested...

     

     

     

     

     

  • Christopher Navarro Profile Picture
    695 on at
    Re: Re: EP Visible = Expression

    Patrice, that worked thanks!

    Now my problem is that the expression errors out when the record is empty/the relation between my tables returns no record to be evaulated and the page complains that the expression must be bound to a record.

    Any thoughts?

  • Christopher Navarro Profile Picture
    695 on at
    Re: Re: Re: EP Visible = Expression

    Anyone?

  • Community Member Profile Picture
    on at
    Re: Re: Re: Re: EP Visible = Expression

     Hi,

     Wouldn't putting in a check for a blank record suffice?

  • Community Member Profile Picture
    on at
    Re: Re: Re: EP Visible = Expression

    What is this control or its container ? Usually an ASP.NET control (gridview, formview etc) won't be rendered if the data source doesn't contain anything. If this control is binded explicitely, you could add a blank row in the data source (is this a dataset ?).

    Some controls have also a template you could use when the data source is empty.

    I'm not really fluent regarding using ASP.NET in the context of the AX portal. I just know about ASP.NET itself...

     

  • Christopher Navarro Profile Picture
    695 on at
    Re: Re: Re: Re: EP Visible = Expression

    Patrice,

    The control is grid and it is bound to a dataset.  What I'm doing is filter the dataset based on a record selected in another control on the page by passing record context to it.

    The problem is that the visibility formula created for the control fails with the error mentioned above when there is no record passed by the main control context.

     I think Bob is onto something; I'll try testing for null instead of "0" later on and will report back my findings.

     Thanks for your help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans