<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<title>DataGrid CellPadding Property</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server" src="fetchData_sql.cs" />
<script language="C#" runat="server">
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
for ( int i=1; i <= 15; i+=2 ) {
PadSelect.Items.Add ( i.ToString ( ) );
}
PadSelect.SelectedIndex = 2;
string query = "SELECT Lastname, Firstname, Address, City, Country FROM Employees";
myGrid.DataSource = fetchData ( query );
myGrid.DataBind ( );
}
myGrid.CellPadding = int.Parse ( PadSelect.SelectedItem.Text );
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>DataGrid CellPadding Property</h2></div>
<hr size=1 width=92%>
<div align="center">
<h5><i>CellPadding</i> refers to the space between a DataGrid cell's content and
its borders.</h5>
<form runat="server">
<p>Select cellpadding ( in pixels )
<asp:dropdownlist id="PadSelect" autopostback runat="server" /></p>
<asp:datagrid id="myGrid" runat="server"
width="95%"
font-size="9pt"
headerstyle-backcolor="lightsteelblue"
headerstyle-font-bold
backcolor="ghostwhite" />
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>