开发者

Hyperlink url for an asp.net gridview column

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")%></I开发者_开发问答temTemplate>
                                    </asp:TemplateField>
                                  <asp:boundfield datafield="Extension" headertext="File Type"/>


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

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


You would need a custom column for that:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜