<%@ Import namespace="System.Data" %>
<HTML>
	<HEAD>
		<script language="C#" runat="server">

        void Page_Load(Object sender, EventArgs e ) {
        
            if (!Page.IsPostBack) {
            
                DataTable dt = new DataTable();
                DataRow dr;

                dt.Columns.Add(new DataColumn("列号", typeof(Int32)));
                dt.Columns.Add(new DataColumn("项目", typeof(string)));
                dt.Columns.Add(new DataColumn("日期", typeof(DateTime)));
                dt.Columns.Add(new DataColumn("布尔值", typeof(bool)));

                for (int i = 1; i <= 9; i++) {
                
                    dr = dt.NewRow();

                    dr[0] = i;
                    dr[1] = "Item " + i.ToString();
                    dr[2] = DateTime.Now;
                    dr[3] = (i % 2 != 0) ? true : false;

                    dt.Rows.Add(dr);
                }
           
                dataGrid1.DataSource = new DataView(dt);
                dataGrid1.DataBind();
            }
        }

		</script>
	</HEAD>
	<body>
		<h3><font face="Verdana">将DataView绑定到DataGrid</font></h3>
		<form runat="server" ID="Form1">
			<asp:DataGrid id="dataGrid1" runat="server" BorderColor="black" BorderWidth="1" GridLines="Both"
				CellPadding="3" CellSpacing="0" HeaderStyle-BackColor="#aaaadd" />
		</form>
	</body>
</HTML>
