各位请帮忙,DataGrip 的入门问题,在线等
为什么看书上的例子,DataGrip都出不来呢?
文件: WebForm1.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.DataGrid dgr_test;
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
ICollection CreateDataSource()
{
DataTable dt = new DataTable();
DataRow dr;
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
for (int i = 0; i <= 8; i++)
{
dr = dt.NewRow();
dr[0] = i;
dr[1] = "Item " + i.ToString();
dr[2] = 1.23 * (i + 1);
dt.Rows.Add(dr);
}
DataView dv = new DataView(dt);
return dv;
}
private void Page_Load(object sender, System.EventArgs e)
{
dgr_test.DataSource =CreateDataSource();
dgr_test.DataBind();
}
}
}
文件 WebForm1.aspx
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta content="Microsoft Visual Studio 7.0" 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">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT id="FONT1" face="宋体">
<asp:DataGrid id="dgr_test" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 80px" runat="server" Width="248px" Height="232px" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" GridLines="Horizontal">
<HeaderStyle BackColor="#00aaaa">
</HeaderStyle>
<ItemStyle BackColor="Yellow">
</ItemStyle>
<AlternatingItemStyle BackColor="LightGreen">
</AlternatingItemStyle>
<Columns>
<asp:BoundColumn
HeaderText="Number"
DataField="IntegerValue">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Description"
DataField="StringValue">
</asp:BoundColumn>
<asp:BoundColumn
HeaderText="Price"
DataField="CurrencyValue" >
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
<asp:Label id="Label1" style="Z-INDEX: 102; LEFT: 200px; POSITION: absolute; TOP: 24px" runat="server" Height="24px" Width="64px">DataGrip</asp:Label></FONT></form>
</body>
</HTML>