“Floating” Gridview Header

后端 未结 3 1708
花落未央
花落未央 2020-12-22 09:34

Is there a way in ASP.NET to have a \"floating\" header, much like a header you would see in an Excel sheet that follows you down the page as you scroll?

Or alternat

3条回答
  •  情书的邮戳
    2020-12-22 09:51

    Try the following (asp.net forums):

    1. Add locked Css:

    td.locked, th.locked {
        position:relative;    
        left:expression((this.parentElement.parentElement.parentElement.parentElement.scrollLeft-2)+'px');
    }   
    

    2. In RowDataBound event add css to GridView cell:

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[0].CssClass = "locked";
        }
    }
    

提交回复
热议问题