zoukankan      html  css  js  c++  java
  • 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# EPPlus 导出Excel
    NetCore +EF+Mysql 从数据库生成实体类到项目
    VBA链接SQL server数据库
    sqlserver中的 binary varbinary image
    sql server DateTime与DateTime2的区别
    Sql Server增删改查字段的语法
    c#中queue的用法
    Sql Server中不相关的两个数据表的全部显示
    IActionResult的返回值类型
    linux内存映射
  • 原文地址:https://www.cnblogs.com/threestone/p/1813527.html
Copyright © 2011-2022 走看看