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

📄 grid.aspx

📁 visual studio.net学习资料
💻 ASPX
字号:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<HTML>
<body>
<SCRIPT language="C#" runat="Server"> 
void Page_Load(object src , EventArgs E) 
{
   DataSet ds;
   SqlConnection conn;
   SqlDataAdapter cmdAuthors;
   DataView dv;

   //create a connection to the Pubs database    
   //conn = new SqlConnection("data source=(local);uid=sa;pwd=;initial catalog=pubs;integrated security=SSPI;persist security info=True");
   //data source=SHA-SHIGAO-VS7\\NETSDK;initial catalog=Northwind;
   conn = new SqlConnection("data source=(local);initial catalog=pubs;integrated security=SSPI;persist security info=True");

   //create a dataset with information from the authors table
   cmdAuthors = new SqlDataAdapter("select * from Authors", conn);
   ds = new DataSet();
   cmdAuthors.Fill(ds, "Authors");

   //bind the first datagrid to the DefaultView of the dataset
   dv = ds.Tables["Authors"].DefaultView;
   dgAuthors.DataSource = dv;
   dgAuthors.DataBind();

   //create a new DataView that is authors from California
   //and bind the second datagrid to it
   dv = new DataView(ds.Tables["Authors"]);
   dv.RowFilter = "state = 'CA'";
   dgCAAuthors.DataSource = dv;
   dgCAAuthors.DataBind();

}
		</SCRIPT>
		<h2>
			All Authors
		</h2>
		<ASP:DataGrid id="dgAuthors" runat="server" Width="700" BackColor="#ccccff" BorderColor="black" ShowFooter="false" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" />
		<H2>
			California Authors
		</H2>
		<ASP:DataGrid id="dgCAAuthors" runat="server" />
	</body>
</HTML>

⌨️ 快捷键说明

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