Click here to Skip to main content
11,414,234 members (71,668 online)
Click here to Skip to main content
Add your own
alternative version

Fixing a Header in Datagrid

, , 25 Jun 2009 CPOL
A simple way to fix the Datagrid header using JavaScript and CSS
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Div.Attributes.Add("onscroll", "setonScroll(this,'" + dgCheckScrollingHeader.ClientID + "');");
        }
        DataGridSource[] dgs = new DataGridSource[32];
        for (int i = 0; i < 32; i++)
        {
            dgs[i] = new DataGridSource();
            dgs[i].Col1Data = "This is a Col1 Data at Row:" + (i + 1).ToString();
            dgs[i].Col2Data = "This is a Col2 Data at Row:" + (i + 1).ToString();
            dgs[i].Col3Data = "This is a Col3 Data at Row:" + (i + 1).ToString() +" To make the text bigger and test this is string is increased";
        }
        dgCheckScrollingHeader.DataSource = dgs;
        dgCheckScrollingHeader.DataBind();
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Authors

S.Rajeshwar
Web Developer
India India
No Biography provided

raj8696
Web Developer
India India
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150427.2 | Last Updated 26 Jun 2009
Article Copyright 2009 by S.Rajeshwar, raj8696
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid