冻结最后几行,前几列和网格View的标题 [英] Freezing few last rows, first few columns and header of grid View

查看:50
本文介绍了冻结最后几行,前几列和网格View的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请建议任何解决方法来冻结我的网格视图的最后4行。



我已成功冻结标题行并留下2列。并且根据要求我还需要冻结最后4行。

Please suggest any workaround to freez the last 4 rows of my Grid View.

I have successfully freezed the header row and left 2 columns. And as per the requirement I need to freez the last 4 row also.

推荐答案

我终于能够freez / Lock Header,最后几行和第一列gridview。

我将很快发布代码。
I am finally able to freez/Lock Header, Last few rows and first column of the gridview.
I will be posting the code soon.


这是代码

--------- -----------

代码背后

==============

protected void Page_Load(object sender,EventArgs e)

{

DataTable dt = new DataTable();

dt.Columns.Add( C1);

dt.Columns.Add(C2);

dt.Columns.Add(C3);

dt.Columns.Add(C4);

dt.Columns.Add(C5);

dt.Columns.Add(C6);

dt.Columns.Add(C7);

dt.Columns.Add(C8);

dt.Columns。添加(C9);

dt.Columns.Add(C10);

DataRow drR ow;

for(int i = 0;我< 10; i ++)

{

drRow = dt.NewRow();

drRow [0] =C10000000+ i;

drRow [1] =C20000000+ i;

drRow [2] =C30000000+ i;

drRow [3] =C40000000 + i;

drRow [4] =C50000000+ i;

drRow [5] =C60000000+ i;

drRow [6] =C70000000+ i;

drRow [7] =C80000000+ i;

drRow [8] =C90000000+ i;

drRow [9] =C100000000+ i;



dt.Rows.Add(drRow);



}



GridView1.DataSource = dt;

GridView1.DataBind();

GridView1.Rows [9] .Cells [0] .ID =footerCell;

GridView1.Rows [9] .Attributes.Add (class,frozenFooter);



}



protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

{

e.Row.Cells [0] .CssClass =frozenCell;



}

带CSS的ASPX页面

======================

Here is the code
--------------------
Code Behind
==============
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("C1");
dt.Columns.Add("C2");
dt.Columns.Add("C3");
dt.Columns.Add("C4");
dt.Columns.Add("C5");
dt.Columns.Add("C6");
dt.Columns.Add("C7");
dt.Columns.Add("C8");
dt.Columns.Add("C9");
dt.Columns.Add("C10");
DataRow drRow;
for (int i = 0; i < 10; i++)
{
drRow = dt.NewRow();
drRow[0] = "C10000000" + i;
drRow[1] = "C20000000" + i;
drRow[2] = "C30000000" + i;
drRow[3] = "C40000000" + i;
drRow[4] = "C50000000" + i;
drRow[5] = "C60000000" + i;
drRow[6] = "C70000000" + i;
drRow[7] = "C80000000" + i;
drRow[8] = "C90000000" + i;
drRow[9] = "C100000000" + i;

dt.Rows.Add(drRow);

}

GridView1.DataSource = dt;
GridView1.DataBind();
GridView1.Rows[9].Cells[0].ID = "footerCell";
GridView1.Rows[9].Attributes.Add("class", "frozenFooter");

}

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Cells[0].CssClass = "frozenCell";

}
ASPX Page with CSS
======================
<head runat="server">
    <title>Untitled Page</title>

    <script src="Javascript/jquery-1.4.2.min.js" type="text/javascript"></script>

    <script src="Javascript/jquery-ui-1.8.5.custom.min.js" type="text/javascript"></script>
    <style type="text/css">


    .frozenFooter
    {
        font-weight:bold;
        background-color: Green;
        color: Black;
        position: relative;
        bottom:expression(getScrollBottom(this.parentNode.parentNode.parentNode.parentNode));
    }

    .frozenCell  {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    background-color: Gray;
    color:Black ;
    border-right: 1px solid silver;
    position:relative;
    cursor: default;
    /*IE5+ only*/
    /*left: expression(document.getElementById("div-datagrid").scrollLeft-2);*/
    /*left:expression((this.parentElement.parentElement.parentElement.parentElement.scrollLeft-2)+'px');*/

    left: expression(document.getElementById("pnlContainer").scrollLeft-2);
    }
    .lockedForLastRow  {
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    background-color: Gray;
    color:Black ;
    border-right: 1px solid silver;
    position:relative;
    cursor: default;
    /*IE5+ only*/
    /*left: expression(document.getElementById("div-datagrid").scrollLeft-2);*/
    /*left:expression((this.parentElement.parentElement.parentElement.parentElement.scrollLeft-2)+'px');*/

    left: expression(document.getElementById("pnlContainer").scrollLeft-2);
    }
    .frozenHeader
    {
        font-size: 14px;
        font-weight: bold;
        text-align: center;
        background-color: Green;
        color:Black ;
        border-right: 1px solid black;
        position:relative;
        cursor: default;
        top: expression(document.getElementById("pnlContainer").scrollTop-2);
        z-index : 10;
    }

    </style>
    <script language="javascript" type="text/javascript">


(document) .ready(function(){
// alert();
//调试器;
//
(document).ready(function() { //alert(""); //debugger; //


这篇关于冻结最后几行,前几列和网格View的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆