⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 第一个简单的例子.txt

📁 C# 是创新性的新式编程语言
💻 TXT
字号:
1*.aspx

<%@ Page language="c#" Codebehind="MyGrid.aspx.cs" AutoEventWireup="false" Inherits="Co_112.MyGrid" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>MyGrid</title>
		<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" Content="C#">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 72px; POSITION: absolute; TOP: 64px" runat="server"
				CellPadding="2" CellSpacing="2" GridLines="None" BorderStyle="Solid" BorderColor="#000000"
				BorderWidth="1" Font-Size="x-small" Font-Names="verdana" AlternatingItemStyle-BackColor="palegoldenrod"
				ItemStyle-BackColor="beige" HeaderStyle-ForeColor="white" HeaderStyle-BackColor="brown" Font-Bold="true"></asp:DataGrid>
		</form>
	</body>
</HTML>

2.*.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;
using System.Data.SqlClient;
namespace Co_112
{
	/// <summary>
	/// MyGrid 的摘要说明。
	/// </summary>
	public class MyGrid : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!Page.IsPostBack)
			{
				string strConn,strCmd;
				strConn="server=localhost;uid=sa;pwd=;database=Northwind";
				strCmd="Select employeeid,firstName,lastName From employees";
				SqlDataAdapter oCMD=new SqlDataAdapter(strCmd,strConn);
				DataSet oDS=new DataSet();
				oCMD.Fill(oDS,"EmployeesList");
				DataTable dt=oDS.Tables["EmployeesList"];
				DataGrid1.DataSource=oDS.Tables["EmployeesList"];
				DataGrid1.DataBind();
				oDS.Dispose();
				oDS=null;
				oCMD.Dispose();
				oCMD=null;

			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -