• HyperLinkField


    ////////////////////////aspx

     <asp:GridView ID="gvData" runat="server" Style="border: 0px; cursor: hand;" AutoGenerateColumns="False"
            ShowHeader="True" Width="710" onclick="javascript:GoSel(event);" OnRowCreated="gvData_RowCreated">
            <Columns>
                <asp:BoundField DataField="编号" HeaderText="编号" />
                <asp:TemplateField>
                    <HeaderTemplate>
                        序号
                    </HeaderTemplate>
                    <ItemTemplate>
                        <%#Container.DataItemIndex+1 %>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" Width="65" />
                </asp:TemplateField>
                <asp:BoundField DataField="文件版本" HeaderText="文件版本">
                    <ItemStyle HorizontalAlign="Center" Width="143" />
                </asp:BoundField>
                <asp:BoundField DataField="手机品牌" HeaderText="手机品牌" />
                <asp:BoundField DataField="手机型号" HeaderText="手机型号" />
                <asp:BoundField DataField="上传日期" HeaderText="上传日期" DataFormatString="{0:yyyy-MM-dd}">
                    <ItemStyle Width="100" />
                </asp:BoundField>
                <asp:BoundField DataField="上传人" HeaderText="上传人"></asp:BoundField>
                <asp:HyperLinkField Text="下载"  HeaderText="下载附件" DataNavigateUrlFields="上传文件" />                 
            </Columns>
        </asp:GridView>

    ///////////////////js

    var selTr = null;
    var preTrBG;
    function GoSel(evt) {
        try {
            var el = evt.srcElement ? evt.srcElement : evt.target;
            if (el.tagName.toUpperCase() != "TD") return;
            var tr = el.parentNode;
            if (tr == null)
                return;

            document.getElementById("hdfID").value = tr.cells[0].innerHTML;
            if (selTr != null) {
                selTr.style.backgroundColor = preTrBG;
            }
            preTrBG = tr.style.backgroundColor;
            selTr = tr;
            tr.style.backgroundColor = "#CCCDDD";
        }
        catch (err) {
        }
    }

    ///////////////////////////////////cs

     protected void gvData_RowCreated(object sender, GridViewRowEventArgs e)
            {
                int iPod = 0;
               
                if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
                {
                    e.Row.Cells[0].Style.Add("display", "none");
                }
                string url = Request.Url.ToString();
                iPod = url.IndexOf("/SystemManage/SysFileUpload.aspx");

                url = url.Substring(0, iPod).Replace("http://","");
                iPod=url.IndexOf("/");
                url=url.Substring(0,iPod);

                string url1 = System.Configuration.ConfigurationManager.AppSettings["cdcshowupload"].Replace("http://", "");
                //if (url1.EndsWith("/"))
                //    url1 = url1.Substring(0, url1.Length - 1);
                iPod = url1.IndexOf('/');
                url1 = "http://"+url + url1.Substring(iPod);
                ((HyperLinkField)this.gvData.Columns[7]).DataNavigateUrlFormatString = url1+"{0}";
            }

  • 相关阅读:
    C# 如何定义让PropertyGrid控件显示[...]按钮,并且点击后以下拉框形式显示自定义控件编辑属性值
    “Word自动更改后的内容保存到通用文档模板上。是否加载该模板?“的解决办法
    Web服务器之iis,apache,tomcat三者之间的比较
    [转]C#如何把文件夹压缩打包然后下载
    [转]C#压缩打包文件
    C#——Marshal.StructureToPtr方法简介
    [Android Pro] 内容提供者ContentProvider的基本使用
    [Linux] awk命令详解
    [Linux] AWK命令详解(大全)
    [Android UI] ProgressBar自定义
  • 原文地址:https://www.cnblogs.com/threestone/p/1813527.html
Copyright © 2020-2023  润新知