Set item style, header style and alternating item style for the asp datagrid (C#) : DataGrid « Asp Control « ASP.Net

ASP.Net
1. ADO.net Database
2. Asp Control
3. Collections
4. Components
5. Data Binding
6. Development
7. HTML Control
8. Mobile Control
9. Page
10. Request
11. Response
12. Server
13. Session Cookie
14. User Control and Master Page
15. Validation by Control
16. Validation by Function
17. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
ASP.Net » Asp Control » DataGrid 
Set item style, header style and alternating item style for the asp datagrid (C#)

<%@Page Language="C#"%>
<html>
<body>

<asp:datagrid  id="dgrTest" runat="server"
               forecolor="#000000"
               backcolor="#ffffff"
               cellpadding="3"
               gridlines="none"
               width="50%"
               font-name="tahoma,arial,sans-serif"
               font-size="14px">
  <headerstyle forecolor="#ffffff"
               backcolor="#808080"
               font-name="tahoma,arial,sans-serif"
               font-size="12px"
               font-bold="true"
               wrap="false" />
  <itemstyle   font-name="tahoma,arial,sans-serif"
               font-size="10px" />
  <alternatingitemstyle font-name="tahoma,arial,sans-serif"
               font-size="16px"
               backcolor="#ffff00" />
</asp:datagrid>

</body>
</html>

<script Language="C#" runat="server">

void Page_Load() {

   // create an ArrayList of values to bind to
   ArrayList arrValues = new ArrayList(4);
   arrValues.Add("A");
   arrValues.Add("B");
   arrValues.Add("C");
   arrValues.Add("D");
   arrValues.Add("E");

   // set the DataSource property of the control to the
   // array and bind it to display the values
   dgrTest.DataSource = arrValues;
   dgrTest.DataBind();

}

</script>

           
       
Related examples in the same category
1. Add data to datagrid (VB.net)
2. BorderColor, CellPadding, CellSpacing for ASP:DataGrid (VB.net)
3. Font-Name, Font-Size for ASP:DataGrid (VB.net)
4. ForeColor, BackColor for ASP:DataGrid (VB.net)
5. AlternatingItemStyle-ForeColor, AlternatingItemStyle-BackColor for ASP:DataGrid (VB.net)
6. AlternatingItemStyle-Font-Name, AlternatingItemStyle-Font-Italic (VB.net)
7. HeaderStyle-BackColor, HeaderStyle-Font-Bold (VB.net)
8. Add button to asp:DataGrid (VB.net)
9. Add hyperlink a asp:datagrid (VB.net)
10. Add hyperlink to asp:datagrid table column (VB.net)
11. Add navigator to asp:datagrid (VB.net)
w___w___w__._j__a__va_2___s___._c_om | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.