Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hide hyperlink is asp.net page if navigate URL is null

Posted on 2015-02-15
4
Medium Priority
?
898 Views
Last Modified: 2015-02-16
I have several hyperlinks on a asp.net web form that are getting the navigate URL value by using databinding.   I have no problem with displaying the links with the URL.    If no problem with navigate url value is returned for a hyperlink but I no value is return I want to hind the link by setting the visible property to false.   I am not sure how to do it.

Here is how I am getting the navigate URL value:

 <asp:HyperLink ID="HyperLink1" Visible="true" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "article_url")%>' runat="server">Click here for more information</asp:HyperLink>
                                 
Any help would be appreciated.

Thanks
0
Comment
Question by:Mike_Stevens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 20

Expert Comment

by:Daniel Van Der Werken
ID: 40611222
This is how I'd do it. First, I'd add an override for the SaveStateComplete event in my code behind.

Then, in this event, I'd check to see if the value for the NavigateUrl for that element is string.Emtpy or null. If it is, then set the element to Visible = false.
0
 
LVL 8

Expert Comment

by:Naitik Gamit
ID: 40611903
look at this link,conversation how to hide hyperlink if data is null

http://stackoverflow.com/questions/19059859/hide-hyperlink-if-data-is-null

hope this will help you to solve the problem.
0
 
LVL 15

Accepted Solution

by:
Lokesh B R earned 2000 total points
ID: 40612036
Hi,

You hide like this.

 <asp:HyperLink ID="HyperLink1" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "article_url")%>' runat="server"
  Visible='<%# DataBinder.Eval(Container.DataItem, "article_url")!= null ? true : false  %>'>Click here for more information</asp:HyperLink>

Open in new window

0
 

Author Comment

by:Mike_Stevens
ID: 40612724
Lokesh.....your example causes syntax errors.  

it runs a 'syntax error' and Error 11      'null' is not declared. 'Null' constant is no longer supported; use 'System.DBNull' instead.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question