Datagrid TemplateColumn

Discussion in 'ASP .Net' started by Jake K, Jan 8, 2007.

  1. Jake K

    Jake K Guest

    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.
    Jake K, Jan 8, 2007
    #1
    1. Advertising

  2. Jake K wrote:
    > 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.
    Jim in Arizona, Jan 9, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob
    Replies:
    0
    Views:
    611
  2. =?Utf-8?B?U3RldmUgUg==?=

    Image TemplateColumn DataGrid Viewstate

    =?Utf-8?B?U3RldmUgUg==?=, Feb 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    388
    =?Utf-8?B?U3RldmUgUg==?=
    Feb 26, 2004
  3. =?Utf-8?B?U3RldmUgUg==?=

    TemplateColumn of DataGrid

    =?Utf-8?B?U3RldmUgUg==?=, Mar 1, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    437
    Brian K. Williams
    Mar 3, 2004
  4. Jade Seguin
    Replies:
    2
    Views:
    476
    Elad Volpin
    Aug 2, 2004
  5. dana lees
    Replies:
    3
    Views:
    5,033
    Eliyahu Goldin
    Sep 7, 2004
Loading...

Share This Page