Hiding the anchor tag in asp.net 1.1 based on condition - help me

V

vishnu

Hi,

I have a link that is coming from the database.Now if the link is
empty i dont want to display in datalist .How can i do that?

<td><asp:DataList id="DataList1" Runat="server"
RepeatDirection="Horizontal" RepeatColumns="3" CellPadding="5"
CellSpacing="2" Width="100%" EnableViewState="False">
<itemtemplate>
<b>
<%# DataBinder.Eval(Container.DataItem, "FIRST_NAME") %>
<%# DataBinder.Eval(Container.DataItem, "MIDDLE_NAME") %>
<%# DataBinder.Eval(Container.DataItem, "LAST_NAME") %>
</b>
<br>
<%# DataBinder.Eval(Container.DataItem, "ADDRESS1") %>
<%# DataBinder.Eval(Container.DataItem, "ADDRESS2") %>
<br>
<%# DataBinder.Eval(Container.DataItem, "CITY") %>
<%# DataBinder.Eval(Container.DataItem, "STATE") %>
<%# DataBinder.Eval(Container.DataItem, "ZIP_CODE") %>
<br>
<%# DataBinder.Eval(Container.DataItem, "TELEPHONE") %>
<br>
<%# DataBinder.Eval(Container.DataItem, "EMAIL") %>
<br>
<a id="Resume" href="<%#
DataBinder.Eval(Container.DataItem, "BIO_RESUME") %>" name="Resume"
Target="_blank">click here for bio/resume</a></b>
</itemtemplate>
</asp:DataList></td>


Thanks,
Vishnu
 
R

Rad [Visual C# MVP]

A quick solution is in your query return a # when the url field is
null
 
V

vishnu

Hi,
Thanks for your suggestion. I have written a function to handle this.

public string ShowLink(object row)
{
string resume=DataBinder.Eval(row,"BIO_RESUME") as string;
if(resume==null || resume.Trim().Length==0)
{
return "<p>No Data</p>";

}
else
return "<a href='<%#Container.DataItem %>' Target="_blank"'>" +
+ "View Bio Resume</a>";
}


Please let me know if this works.

Thanks,
Vishnu
 
V

vishnu

Hi,
Thanks for your suggestion. I have written a function to handle this.

public string ShowLink(object row)
{
string resume=DataBinder.Eval(row,"BIO_RESUME") as string;
if(resume==null || resume.Trim().Length==0)
{
return "<p>No Data</p>";

}
else
return "<a href='<%#Container.DataItem %>' Target="_blank"'>" +
+ "View Bio Resume</a>";
}


Please let me know if this works.

Thanks,
Vishnu
 

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

Top