Datagrid TemplateColumn


J

Jake K

I have an ItemTemplate in a datagrid that must use a conditional statement.
The templatecolumns is as follows:

<asp:TemplateColumn HeaderText="Listen To File">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" ImageUrl="sound.gif"
NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.path_to_file",
"{0:g}") %>'>
</ItemTemplate>
</asp:TemplateColumn>

I only want to display the hyprlink/sound.gif if dataitem.patch_to_file
contains a string. So if the value of path_to_file is null or empty then I
do not want to display the sound.gif. Path_to_file in the database may be
something like http://.../whatver.wav or may be null or empty.

Can this be accomplished? Thanks a lot for the advise.
 
Ad

Advertisements

J

Jim in Arizona

Jake said:
I have an ItemTemplate in a datagrid that must use a conditional statement.
The templatecolumns is as follows:

<asp:TemplateColumn HeaderText="Listen To File">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" ImageUrl="sound.gif"
NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.path_to_file",
"{0:g}") %>'>
</ItemTemplate>
</asp:TemplateColumn>

I only want to display the hyprlink/sound.gif if dataitem.patch_to_file
contains a string. So if the value of path_to_file is null or empty then I
do not want to display the sound.gif. Path_to_file in the database may be
something like http://.../whatver.wav or may be null or empty.

Can this be accomplished? Thanks a lot for the advise.

How is the data retrieved from the database? Could this be something you
could solve in your SQL statements, but removing any empty or null
values with your select statement(s) before the processing is started by
asp.net? Other than that, I don't know how you could fix this.
 

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