Breaking News

Editors Picks

Tuesday, December 20, 2011

Scrollable GridView With Fixed Headers Asp.Net


 Their is two way to show Headers

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebFrmforTest.aspx.cs" Inherits="WebFrmforTest" %>

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Pagetitle>
<style type="text/css">
.fixedHeader
{
font-weight: bold;
position: relative;
background-color: #336699;
color: #ffffff;
height: 20px;
}
style>
head>
<body>
<form id="form1" runat="server">
<div style="position: relative">
<table>
<tr>
<td>
First way to show header  
td>
tr>
<tr>
<td>
<asp:Panel ID="Panel1" runat="server" Width="644px" ScrollBars="Vertical">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" ShowHeader="true"
Width="636px" Height="208px">
<Columns>
<asp:TemplateField HeaderText="POP_Name" InsertVisible="true">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("POP_Name") %>'>asp:Label>
ItemTemplate>
asp:TemplateField>
<asp:TemplateField HeaderText="State">
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Eval("State") %>'>asp:Label>
ItemTemplate>
asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:Label ID="Label111" runat="server" Text='<%# Eval("City") %>'>asp:Label>
ItemTemplate>
asp:TemplateField>
Columns>
<HeaderStyle CssClass="fixedHeader" />

asp:GridView>
asp:Panel>
td>
tr>
<tr>
<td>
second way to show header  
td>
tr>
<tr>
<td>
<table>
<tr>
<td>
<table style="border-width: 0px; width: 100%; border-collapse: collapse; background-color: Black;
color: White;" cellspacing="0" border="1">
<tr>
<td align="center" width="13%">
<b>POP_Nameb>
td>
<td align="center" width="13%">
<b>Stateb>
td>
<td align="center" width="10%">
<b>Cityb>
td>
tr>
table>
td>
tr>
<tr>
<td>
<asp:Panel ID="Panel2" runat="server" Width="100%" ScrollBars="Vertical">
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" ShowHeader="false"
Width="499px" Height="99px">
<Columns>
<asp:TemplateField HeaderText="POP_Name" InsertVisible="true">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("POP_Name") %>'>asp:Label>
ItemTemplate>
<HeaderStyle Width="20%" HorizontalAlign="Center" />
asp:TemplateField>
<asp:TemplateField HeaderText="State">
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Eval("State") %>'>asp:Label>
ItemTemplate>
<HeaderStyle Width="20%" HorizontalAlign="Center" />
asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:Label ID="Label111" runat="server" Text='<%# Eval("City") %>'>asp:Label>
ItemTemplate>
<HeaderStyle Width="10%" HorizontalAlign="Center" />
asp:TemplateField>
Columns>
asp:GridView>
asp:Panel>
td>
tr>
table>
td>
tr>
<tr>
<td>

td>
tr>
table>
div>
form>
body>
html>

Read more ...

Contact Us

Name

Email *

Message *