Link to home
Start Free TrialLog in
Avatar of Jeff Fillegar
Jeff FillegarFlag for United States of America

asked on

asp.net - gridview dynamic hyperlink item templates

Hello Experts,
c#, asp.net, dynamic data web application:

I have a gridview that displays a hyperlink for the FILENAME column.  The text displayed to the user is "VIEW FILE".  When the user clicks on it a new browser is displayed with the contents of that file.  Here is the gridview code:
            <asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource" EnablePersistedSelection="true"
                AllowPaging="True" AllowSorting="True" CssClass="DDGridView"
                RowStyle-CssClass="td" HeaderStyle-CssClass="th" CellPadding="6"
                AutoGenerateColumns="false">
                <Columns>
                    <asp:DynamicField DataField="SCENARIO" />
                    <asp:DynamicField DataField="SERVER" />
                    <asp:DynamicField DataField="RESULT" />
                    <asp:TemplateField HeaderText="FILENAME">
                    <ItemTemplate>
                    <asp:HyperLink runat="server" ID="FILENAME" NavigateUrl='<%# Eval("FILENAME") %>' Target="_blank"  >VIEW FILE</asp:HyperLink> 
                    </ItemTemplate>
                    </asp:TemplateField>                    
                    <asp:TemplateField>
                        <ItemTemplate>                        
                            <asp:DynamicHyperLink runat="server" Action="Edit" Text="Edit"
                            />&nbsp;<asp:LinkButton runat="server" CommandName="Delete" Text="Delete"
                                OnClientClick='return confirm("Are you sure you want to delete this item?");'
                            />&nbsp;<asp:DynamicHyperLink runat="server" Text="Details" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>            

Open in new window


What I would like to do is not display the text "VIEW FILE" if that column does not have a file (empty string or null).  Any ideas?
ASKER CERTIFIED SOLUTION
Avatar of CtrlAltDl
CtrlAltDl
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeff Fillegar

ASKER

That was easy.  Thanks.