Click here to Skip to main content
Click here to Skip to main content

Add some Style to your DataGrids

By , 5 Jul 2004
 
<%@ Page language="c#" Codebehind="MyGrid.aspx.cs" AutoEventWireup="false" Inherits="GridStyles.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>WebForm1</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="C#" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK title="Tan" media="screen" href="styles.css" type="text/css" rel="stylesheet">
		<LINK title="Blue" media="screen" href="styles2.css" type="text/css" rel="stylesheet">
		<LINK title="print" media="print" href="printstyles.css" type="text/css" rel="stylesheet">
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<h1>Table 1 - no sorting or paging</h1>
			<asp:datagrid id="DataGrid1" runat="server" CssClass="Grid">
				<HeaderStyle CssClass="GridHeader"></HeaderStyle>
				<ItemStyle CssClass="GridItem"></ItemStyle>
				<AlternatingItemStyle CssClass="GridAltItem"></AlternatingItemStyle>
			</asp:datagrid>
			<h1>Table 2 - with sorting and paging</h1>
			<asp:DataGrid id="DataGrid2" runat="server" AllowSorting="True" CssClass="Grid" AllowPaging="True">
				<AlternatingItemStyle CssClass="GridAltItem"></AlternatingItemStyle>
				<ItemStyle CssClass="GridItem"></ItemStyle>
				<HeaderStyle CssClass="GridHeader"></HeaderStyle>
				<PagerStyle CssClass="GridPager"></PagerStyle>
			</asp:DataGrid></form>
	</body>
</HTML>

By viewing downloads associated with this article you agree to the Terms of use 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)

About the Author

Steven Campbell
Web Developer
United States United States
Member
Steve is a software developer working in Minneapolis, MN.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 6 Jul 2004
Article Copyright 2004 by Steven Campbell
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid