2011-10-11 31 views
3

我有一個從一個目錄路徑返回值,例如一個GridView:超鏈接URL的一個asp.net的GridView列

  <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> 

我怎樣才能獲得「姓名」一欄下的數值也有類似的URL到"javascript:OpenSecure('abcd.doc')

更新: 鑑於下面的HTML代碼,我無法在名稱字段中看到超鏈接。

<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"/> 

+0

在關閉超鏈接標記之前顯示文本。 'runat =「server」><%#Eval(「Name」)%>,或使用Text屬性... – Nalaka526

回答

1

轉換名稱字段<ItemTemplate>並嘗試添加一個超鏈接

<asp:HyperLink ID="hplName" runat="server" NavigateUrl='<%# "javascript:OpenSecure(''' + Eval("Name") ''') %>' Text='<%# Eval("Name") %>'/> 
+0

請參閱我的更新代碼。我無法在名稱字段中看到超鏈接; – Frank