3

I have a gridview that returns values from a directory path such as :

            <table width="40%" border="0" style="margin-left:auto; margin-right:auto;">
                <tr>
                    <td align="center">
                        <asp:GridView ID="gvFileList" runat="server" AutoGenerateColumns="false" AllowSorting="true">
                            <columns>
                              <asp:boundfield datafield="Name" headertext="File Name"/>
                              <asp:boundfield datafield="Extension" headertext="File Type"/>
                              <asp:boundfield datafield="Length" headertext="Length"/>
                              <asp:boundfield datafield="LastCreateTime" headertext="Date"/>
                            </columns>
                        </asp:GridView>
                    </td>
                </tr>
            </table>

How can I get the values under the "Name" column to have a url similar to "javascript:OpenSecure('abcd.doc') ?

Update: Given the HTML code below, I am unable to see the hyperlink in the Name field.

<asp:GridView ID="gvInvoiceList" runat="server" AutoGenerateColumns="false" AllowSorting="true">
                                <columns>
                                    <asp:TemplateField HeaderText="Name">
                                        <ItemTemplate><asp:Hyperlink ID="acctInvoiceRpt" NavigateUrl='<%# SetNavigateUrl(Eval("Name")) %>' runat="server"></asp:Hyperlink><%#Eval("Name")%></ItemTemplate>
                                    </asp:TemplateField>
                                  <asp:boundfield datafield="Extension" headertext="File Type"/>

Frank
  • 2,015
  • 10
  • 36
  • 57

2 Answers2

1

You would need a custom column for that:

http://msdn.microsoft.com/en-us/library/ms228046.aspx

Burt
  • 7,680
  • 18
  • 71
  • 127
1

Convert Name field to <ItemTemplate> and try adding a hyperlink

<asp:HyperLink ID="hplName" runat="server"  NavigateUrl='<%# "javascript:OpenSecure(''' + Eval("Name") ''') %>' Text='<%# Eval("Name") %>'/>
Nalaka526
  • 11,278
  • 21
  • 82
  • 116