如题:在一个blog上
http://blog.csdn.net/Samanthaqu/archive/2007/12/04/1915667.aspx 里面介绍了固定表头和首列的详细方法,按照方法固定表头可以实现,但固定首列老是实现不了,哪位高手帮我看一下
http://blog.csdn.net/Samanthaqu/archive/2007/12/04/1915667.aspx 里面介绍了固定表头和首列的详细方法,按照方法固定表头可以实现,但固定首列老是实现不了,哪位高手帮我看一下
解决方案 »
- ASP.NET基于MVC的上传头像的组件
- VS2008无法调试
- 新手求助!请大虾们帮下忙~~SOS!!!!
- 请问有什么比较好的办法解决这个问题吗?
- 如何拒绝来自不同站点向我站点发送的数据请求?
- 我想在后台写个用C#语句,能弹出个对话框,显示几个字,点一下确定就返回
- 简单的程序中调用存储过程问题,有源码1
- 怎样初始化客户端函数,从后台读取数据然后初始化客户端函数
- 无法从带有索引像素格式的图像创建 Graphics 对象?
- 高手帮忙啊,我的水晶报表下载不了
- asp.net 动态添加textbox,并且获取值
- treeview动态目录树一级一级加载节点,比如说一开始只加载一级节点,当点击相应的一级节点时再加载其对应的二级节点,请各位高手指教!!急~~
.fixColleft
{ z-index:120; left: expression(this.offsetParent.scrollLeft); position: relative }
.fixedHeader {
overflow: auto;}
.fixColleft
{ }后台代码:
绑定gridview
this.GridView1.Columns[0].HeaderStyle.CssClass = "fixColleft";
this.GridView1.Columns[0].ItemStyle.CssClass = "fixColleft";
this.GridView1.DataBind();
……
//第一列
<HeaderStyle Width="100px" CssClass="fixColleft"/>
<ItemStyle Width="100px" CssClass="fixColleft"/>
</div>数据记录数为100条。显示的结果是:
能锁定第一列,其中第二、三……可以实现滚动。但第一列显示100条记录,第二、三列……显示10条。为什么会是这样子的啊?
在asp.net中所有的数据库绑定控件都是从BaseDataBoundControl这个抽象类派生的,这个抽象类定义了几个重要属性和一个重要方法:DataSource属性:指定数据绑定控件的数据来源,显示的时候程序将会从这个数据源中获取数据并显示。DataSourceID属性:指定数据绑定控件的数据源控件的ID, 显示的时候程序将会根据这个ID找到相应的数据源控件,并利用这个数据源控件中指定方法获取数据并显示。DataBind()方法:当指定了数据绑定控件的DataSource属性或者DataSourceID属性之后,再调用DataBind()方法才会显示绑定的数据。并且在使用数据源时,会首先尝试使用DataSourceID属性标识的数据源,如果没有设置DataSourceID时才会用到DataSource属性标识的数据源。也就是说DataSource和DataSourceID两个属性不能同时使用。数据绑定控件的DataSource控件属性必须是一个可以枚举的数据源,如实现了ICollection、IEnumerable或IListSource接口的类的实例。
固定表头可以按http://blog.csdn.net/Samanthaqu/archive/2007/12/04/1915667.aspx 里面介绍的方法做可以实现,
固定首列或某一列按1楼的做法做实现不了,
哪位高手能不能自已写个例子将详细的源码贴出来我看一下?最好具体一点。分数不够我再加啊还有拉动向下滚动条的时候表头不动,表内的数据向下移动。当拉动向右滚动条的时候,某一列固定不动(包括有表头和表体),其它列都向右称动(包括表头和表体),这两种能不能同时做到?
如果上面的还是不行的话,试试这个
<style type="text/css">
<!--
body {
background: #FFF;
color: #000;
font: normal normal 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
margin: 10px;
padding: 0
}table, td, a {
color: #000;
font: normal normal 12px Verdana, Geneva, Arial, Helvetica, sans-serif
}.td
{
nowrap:‘’true‘’;
}div.tableContainer {
clear: both;
border: 1px solid #963;
height: 285px;
overflow: auto;
width: 100%;
}/* WinIE 6.x needs to re-account for it‘’s scrollbar. Give it some padding */
\html div.tableContainer/* */ {
padding: 0 16px 0 0
}/* clean up for allowing display Opera 5.x/6.x and MacIE 5.x */
html>body div.tableContainer {
height: auto;
padding: 0;
width: 740px
}/* Reset overflow value to hidden for all non-IE browsers. */
/* Filter out Opera 5.x/6.x and MacIE 5.x */
head:first-child+body div[class].tableContainer {
height: 285px;
overflow: hidden;
width: 756px
}/* define width of table. IE browsers only */
/* if width is set to 100%, you can remove the width */
/* property from div.tableContainer and have the div scale */
div.tableContainer table {
float: left;
width: 100%
}/* WinIE 6.x needs to re-account for padding. Give it a negative margin */
\html div.tableContainer table/* */ {
margin: 0 -16px 0 0
}/* define width of table. Opera 5.x/6.x and MacIE 5.x */
html>body div.tableContainer table {
float: none;
margin: 0;
width: 740px
}/* define width of table. Add 16px to width for scrollbar. */
/* All other non-IE browsers. Filter out Opera 5.x/6.x and MacIE 5.x */
head:first-child+body div[class].tableContainer table {
width: 756px
}/* set table header to a fixed position. WinIE 6.x only */
/* In WinIE 6.x, any element with a position property set to relative and is a child of */
/* an element that has an overflow property set, the relative value translates into fixed. */
/* Ex: parent element DIV with a class of tableContainer has an overflow property set to auto */
thead.fixedHeader tr {
position: relative;
/* expression is for WinIE 5.x only. Remove to validate and for pure CSS solution */
top: expression(document.getElementById("tableContainer").scrollTop)
}
/* set THEAD element to have block level attributes. All other non-IE browsers */
/* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
/* Filter out Opera 5.x/6.x and MacIE 5.x */
head:first-child+body thead[class].fixedHeader tr {
display: block
}/* make the TH elements pretty */
thead.fixedHeader th {
background: #C96;
border-left: 1px solid #EB8;
border-right: 1px solid #B74;
border-top: 1px solid #EB8;
font-weight: normal;
padding: 4px 3px;
text-align: center
}/* make the A elements pretty. makes for nice clickable headers */
thead.fixedHeader a, thead.fixedHeader a:link, thead.fixedHeader a:visited {
color: #FFF;
display: block;
text-decoration: none;
width: 100%
}/* make the A elements pretty. makes for nice clickable headers */
/* WARNING: swapping the background on hover may cause problems in WinIE 6.x */
thead.fixedHeader a:hover {
color: #FFF;
display: block;
text-decoration: underline;
width: 100%
}/* define the table content to be scrollable */
/* set TBODY element to have block level attributes. All other non-IE browsers */
/* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
/* induced side effect is that child TDs no longer accept width: auto */
/* Filter out Opera 5.x/6.x and MacIE 5.x */
head:first-child+body tbody[class].scrollContent {
display: block;
height: 262px;
overflow: auto;
width: 100%
}/* make TD elements pretty. Provide alternating classes for striping the table */
/* http://www.alistapart.com/articles/zebratables/ */
tbody.scrollContent td, tbody.scrollContent tr.normalRow td {
background: #FFF;
border-bottom: 1px solid #EEE;
border-left: 1px solid #EEE;
border-right: 1px solid #AAA;
border-top: 1px solid #AAA;
padding: 2px 3px
}tbody.scrollContent tr.alternateRow td {
background: #EEE;
border-bottom: 1px solid #EEE;
border-left: 1px solid #EEE;
border-right: 1px solid #AAA;
border-top: 1px solid #AAA;
padding: 2px 3px
}/* define width of TH elements: 1st, 2nd, and 3rd respectively. */
/* All other non-IE browsers. Filter out Opera 5.x/6.x and MacIE 5.x */
/* Add 16px to last TH for scrollbar padding */
/* http://www.w3.org/TR/REC-CSS2/selector.html#adjacent-selectors */
head:first-child+body thead[class].fixedHeader th {
width: 200px
}head:first-child+body thead[class].fixedHeader th + th {
width: 250px
}head:first-child+body thead[class].fixedHeader th + th + th {
border-right: none;
padding: 4px 4px 4px 3px;
width: 316px
}/* define width of TH elements: 1st, 2nd, and 3rd respectively. */
/* All other non-IE browsers. Filter out Opera 5.x/6.x and MacIE 5.x */
/* Add 16px to last TH for scrollbar padding */
/* http://www.w3.org/TR/REC-CSS2/selector.html#adjacent-selectors */
head:first-child+body tbody[class].scrollContent td {
width: 200px
}head:first-child+body tbody[class].scrollContent td + td {
width: 250px
}head:first-child+body tbody[class].scrollContent td + td + td {
border-right: none;
padding: 2px 4px 2px 3px;
width: 300px/* expression is for WinIE 5.x only. Remove to validate and for pure CSS solution */
top: expression(document.getElementById("tableContainer").scrollTop)
}
-->
</style>
11楼的方法好像是在哪里抄来的.我刚学.NET不久,请各位大哥大姐在回贴的时候 尽量给个例子,短点就可以了,最好自已亲自测试一下代码再发贴好吗?固定表头同时能固定首列老我还是不知如何做?哪位能帮我解决一下真是万分感谢.请不要在网上随便粘贴一些内容或是看清楚我的问题再回贴可以吗?