• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >ASP.NET > asp.net实现固定GridView标题栏的方法(冻结列功能)

asp.net实现固定GridView标题栏的方法(冻结列功能)

作者:smartsmile2012 字体:[增加 减小] 来源:互联网 时间:2017-05-11

smartsmile2012通过本文主要向大家介绍了gridview asp.net,asp.net,asp net培训,asp和asp.net的区别,零基础学asp.net等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

本文实例讲述了asp.net实现固定GridView标题栏的方法。分享给大家供大家参考,具体如下:

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  protected void Page_Load(object sender, EventArgs e)
  {
    DataTable t = new DataTable();
    t.Columns.Add("序号", typeof(int));
    t.Columns.Add("材料", typeof(string));
    t.Columns.Add("单价", typeof(decimal));
    for (int i = 1; i <= 10; i++)
      t.Columns.Add("库存" + i, typeof(int));
    Random rnd = new Random();
    for (int i = 0; i < 80; i++)
    {
      DataRow row = t.NewRow();
      row["序号"] = i + 1;
      row["材料"] = Guid.NewGuid().ToString().Substring(0, 13).ToUpper();
      row["单价"] = rnd.NextDouble() * 100;
      for (int j = 1; j <= 10; j++)
        row["库存" + j] = rnd.Next(10000);
      t.Rows.Add(row);
    }
    GridView1.AutoGenerateColumns = false;
    foreach (DataColumn c in t.Columns)
    {
      BoundField bf = new BoundField();
      bf.DataField = c.ColumnName;
      bf.HeaderText = c.ColumnName;
      if (c.DataType == typeof(decimal))
        bf.DataFormatString = "{0:#,0.00}";
      else if (c.DataType == typeof(int))
        bf.DataFormatString = "{0:#,0}";
      bf.ItemStyle.HorizontalAlign =
        (!string.IsNullOrEmpty(bf.DataFormatString)) ?
        HorizontalAlign.Right : HorizontalAlign.Center;
      GridView1.Columns.Add(bf);
    }
    GridView1.DataSource = t;
    GridView1.DataBind();
  }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title></title>
  <style type="text/css">
  .altRow { background-color: #ddddff; }
  </style>
  <link href="superTables.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="jquery-1.3.1.js"></script>
  <script type="text/javascript" src="superTables.js"></script>
  <script type="text/javascript" src="jquery.superTable.js"></script>
  <script type="text/javascript">
    $(function() {
      $("#GridView1").toSuperTable({ width: "640px", height: "480px", fixedCols: 2 })
      .find("tr:even").addClass("altRow");
    });
  </script>
</head>
<body>
  <form id="form1" runat="server">
  <asp:GridView ID="GridView1" runat="server" Font-Size="9pt" EnableViewState="false">
  </asp:GridView>
  </form>
</body>
</html>

</div>
// Super Tables Plugin for jQuery - MIT Style License
// Copyright (c) 2009 Jeffrey Lee --- blog.darkthread.net
//
// A wrapper for Matt Murphy's Super Tables http://www.matts411.com/post/super_tables/
//
// Contributors:
//
////// TO CALL:
// $("...").toSuperTable(options)
//
////// OPTIONS: (order does not matter )
// cssSkin : string ( eg. "sDefault", "sSky", "sOrange", "sDark" )
// headerRows : integer ( default is 1 )
// fixedCols : integer ( default is 0 )
// colWidths : integer array ( use -1 for auto sizing )
// onStart : function ( any this.variableNameHere variables you create here can be used later ( eg. onFinish function ) )
// onFinish : function ( all this.variableNameHere variables created in this script can be used in this function )
// margin, padding, width, height, overflow...: Styles for "fakeContainer"
//
////// Example:
// $("#GridView1").toSuperTable(
//       { width: "640px", height: "480px", fixedCols: 2,
//        onFinish: function() { alert('Done!'); } })
// jquery.superTable.js
(function($) {
  $.fn.extend(
      {
        toSuperTable: function(options) {
          var setting = $.extend(
          {
            width: "640px", height: "320px",
            margin: "10px", padding: "0px",
            overflow: "hidden", colWidths: undefined,
            fixedCols: 0, headerRows: 1,
            onStart: function() { },
            onFinish: function() { },
            cssSkin: "sSky"
          }, options);
          return this.each(function() {
            var q = $(this);
            var id = q.attr("id");
            q.removeAttr("style").wrap("<div id='" + id + "_box'></div>");
            var nonCssProps = ["fixedCols", "headerRows", "onStart", "onFinish", "cssSkin", "colWidths"];
            var container = $("#" + id + "_box");
            for (var p in setting) {
              if ($.inArray(p, nonCssProps) == -1) {
                container.css(p, setting[p]);
                delete setting[p];
              }
            }
            var mySt = new superTable(id, setting);
          });
        }
      });
})(jQuery);

</div>
// Super Tables v0.30 - MIT Style License
// Copyright (c) 2008 Matt Murphy --- www.matts411.com
//
// Contributors:
// Joe Gallo
////// TO CALL:
// new superTable([string] tableId, [object] options);
//
////// OPTIONS: (order does not matter )
// cssSkin : string ( eg. "sDefault", "sSky", "sOrange", "sDark" )
// headerRows : integer ( default is 1 )
// fixedCols : integer ( default is 0 )
// colWidths : integer array ( use -1 for auto sizing )
// onStart : function ( any this.variableNameHere variables you create here can be used later ( eg. onFinish function ) )
// onFinish : function ( all this.variableNameHere variables created in this script can be used in this function )
//
////// EXAMPLES:
// var myST = new superTable("myTableId");
//
// var myST = new superTable("myTableId", {
//   cssSkin : "sDefault",
//   headerRows : 1,
//   fixedCols : 2,
//   colWidths : [100, 230, 220, -1, 120, -1, -1, 120],
//   onStart : function () {
//     this.start = new Date();
//   },
//   onFinish : function () {
//     alert("Finished... " + ((new Date()) - this.start) + "ms.");
//   }
// });
//
////// ISSUES / NOTES:
// 1. No quirksmode support (officially, but still should work)
// 2. Element id's may be duplicated when fixedCols > 0, causing getElementById() issues
// 3. Safari will render the header row incorrectly if the fixed header row count is 1 and there is a colspan > 1 in one
//   or more of the cells (fix available)
////////////superTables.js///////////
var superTable = function (tableId, options) {
/////* Initialize */
  options = options || {};
  this.cssSkin = options.cssSkin || "";
  this.headerRows = parseInt(options.headerRows || "1");
  this.fixedCols = parseInt(options.fixedCols || "0");
  this.colWidths = options.colWidths || [];
  this.initFunc = options.onStart || null;
  this.callbackFunc = options.onFinish || null;
  this.initFunc && this.initFunc();
/////* Create the framework dom */
  this.sBase = document.createElement("DIV");
  this.sFHeader = this.sBase.cloneNode(false);
  this.sHeader = this.sBase.cloneNode(false);
  this.sHeaderInner = this.sBase.cloneNode(false);
  this.sFData = this.sBase.cloneNode(false);
  this.sFDataInner = this.sBase.cloneNode(false);
  this.sData = this.sBase.cloneNode(false);
  this.sColGroup = document.createElement("COLGROUP");
  this.sDataTable = document.getElementById(tableId);
  this.sDataTable.style.margin = "0px"; /* Otherwise looks bad */
  if (this.cssSkin !== "") {
    this.sDataTable.className += " " + this.cssSkin;
  }
  if (this.sDataTable.getElementsByTagName("COLGROUP").length > 0) {
    this.sDataTable.removeChild(this.sDataTable.getElementsByTagName("COLGROUP")[0]); /* Making our own */
  }
  this.sParent = this.sDataTable.parentNode;
  this.sParentHeight = this.sParent.offsetHeight;
  this.sParentWidth = this.sParent.offsetWidth;
/////* Attach the required classNames */
  th



 
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • ASP.NET GridView的Bootstrap分页样式
  • asp.net实现固定GridView标题栏的方法(冻结列功能)
  • 在ASP.NET 2.0中操作数据之六十四:GridView批量添加数据
  • 在ASP.NET 2.0中操作数据之六十三:GridView实现批量删除数据
  • 在ASP.NET 2.0中操作数据之六十二:GridView批量更新数据
  • 在ASP.NET 2.0中操作数据之五十一:从GridView的页脚插入新记录
  • 在ASP.NET 2.0中操作数据之四十九:为GridView控件添加RadioButton
  • 在ASP.NET 2.0中操作数据之二十八:GridView里的Button
  • 在ASP.NET 2.0中操作数据之十五:在GridView的页脚中显示统计信息
  • 在ASP.NET 2.0中操作数据之十二:在GridView控件中使用TemplateField

相关文章

  • 2017-05-11VS2010/VS2013项目创建 ADO.NET连接mysql/sql server详细步骤
  • 2017-05-11DataReader深入解析:持续更新
  • 2017-05-11ASP.NET使用gridview获取当前行的索引值
  • 2017-05-11Asp.net Core 1.1 升级后操作mysql出错的解决办法
  • 2017-05-11分享Visual Studio原生开发的10个调试技巧
  • 2017-05-11Asp.Mvc 2.0实现用户登录与注销功能实例讲解(2)
  • 2017-05-11asp.net通过js实现Cookie创建以及清除Cookie数组的代码
  • 2017-05-11asp.net 实现下拉框只读功能
  • 2018-08-20asp.net mvc 动态编译生成Controller的方法
  • 2017-05-11静态gb2312编码在项目传值出现中文乱码现象

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 详解ABP框架中的数据过滤器与数据传输对象的使用
    • asp.net提取多层嵌套json数据的方法
    • 简单的启动窗体
    • ASP.NET MVC5+EF6+EasyUI 后台管理系统(81)-数据筛选(万能查询)实例
    • asp.net 用户控件中图片及样式问题
    • 《解剖PetShop》之三:PetShop数据访问层之消息处理
    • js获取.aspx页面里面的服务器控件和.ascx中的服务器控件值
    • Server.Transfer,Response.Redirect的区别
    • 详解ASP.NET中Session的用法
    • .NET Core利用swagger进行API接口文档管理的方法详解

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有