fixed header in Datagrid,Gridview in asp.net

Posted on May 13, 2008. Filed under: Asp.net |

<head runat=”server”>
<title>Untitled Page</title>
</head>
<script type=”text/javascript”>   
function showheader()
{
var ab= document.getElementById(”<%=gd.ClientID%>”);
var pnid = document.getElementById(”<%=pn.ClientID%>”);
var abc = ab.cloneNode(true);
var i = abc.rows.length -1;
for(;i>0;i–)
abc.deleteRow(i)
ab.deleteRow(0)
pnid.appendChild(abc)
}
window.onload =showheader
</script>

<body>
<form id=”form1″ runat=”server”>
<div><asp:Panel ID=pn runat=server></asp:Panel>
<asp:Panel ID=pnn runat=server style=”overflow-y:scroll;height: 250px;weight:300px” >
<asp:GridView ID=”gd” runat=”server”>
</asp:GridView>
</asp:Panel>
</div>
</form>
</body>
code file//////////
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection(”Server=.;Database=rubru;uid=sa;pwd=sa”);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = “select top 100 * from locality”;
cmd.Connection.Open();
SqlDataReader rdr = cmd.ExecuteReader();
gd.DataSource = rdr;
gd.DataBind();
cmd.Connection.Close();

}

Make a Comment

Make A Comment: ( 1 so far )

blockquote and a tags work here.

One Response to “fixed header in Datagrid,Gridview in asp.net”

RSS Feed for Dream Asp.net Comments RSS Feed

How does it work?
it doesn’t work one mine’s

Fouadibiza
July 6, 2008

Where's The Comment Form?

    About

    Hi,I am Suresh Sharma(MCP) from Gorakhpur , UP, India.I have work on .net technology from 2 years. Key skills-Asp.net 2.0,3.5, Sql 2005,2000. Ajax.net 1.1,C#.net

    RSS

    Subscribe Via RSS

    • Subscribe with Bloglines
    • Add your feed to Newsburst from CNET News.com
    • Subscribe in Google Reader
    • Add to My Yahoo!
    • Subscribe in NewsGator Online
    • The latest comments to all posts in RSS
    • Subscribe in Rojo

    Meta

Liked it here?
Why not try sites on the blogroll...