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

📄 use-dataset-control.aspx

📁 东软内部材料(四)asp等相关的教学案例 
💻 ASPX
字号:
<%@Page Language="C#"%>

<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.OleDb" %>

<%@ Register TagPrefix="wrox" TagName="connect" Src="..\global\connect-strings.ascx" %>
<%@ Register TagPrefix="wrox" TagName="getdataset" Src="..\global\get-dataset-control.ascx" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<title>Using a Control to create a DataSet</title>
<!-- #include file="..\global\style.inc" -->
</head>
<body bgcolor="#ffffff">
<span class="heading">Using a Control to create a DataSet</span><hr />
<!--------------------------------------------------------------------------->

<%-- insert connection string script --%>
<wrox:connect id="ctlConnectStrings" runat="server"/>

<%-- insert the control that creates the DataSet --%>
<wrox:getdataset id="ctlDataSet" runat="server"/>

<b>DataSet.Tables Collection</b>
<asp:datagrid id="dgrTables" runat="server" /><br />
<b>DataSet.Relations Collection</b>
<asp:datagrid id="dgrRelations" runat="server" /><br />
<b>Contents of DataSet.Tables["Books"]</b>
<asp:datagrid id="dgrBooksData" runat="server" /><br />
<b>Contents of DataSet.Tables["Authors"]</b>
<asp:datagrid id="dgrAuthorsData" runat="server" /><br />
<b>Contents of DataSet.Tables["Prices"]</b>
<asp:datagrid id="dgrPricesData" runat="server" />

<script language="C#" runat="server">

	void Page_Load(Object sender, EventArgs e)
	{
		// get connection string from ..\global\connect-strings.ascx user control
		string strConnect = ctlConnectStrings.OLEDBConnectionString;

		// create a variable to hold an instance of a DataSet object
		DataSet  objDataSet;

		// get dataset from get-dataset-control.ascx user control
		objDataSet = ctlDataSet.BooksDataSet(strConnect, "ISBN LIKE '18610033%'");

		if (objDataSet == null)
			return;

		// now we're ready to display the contents of the DataSet object
		// bind the collection of Tables to the first DataGrid on the page
		dgrTables.DataSource = objDataSet.Tables;
		dgrTables.DataBind();

		// bind the collection of Relations to the second DataGrid on the page
		dgrRelations.DataSource = objDataSet.Relations;
		dgrRelations.DataBind();

		// create a DataView object to use with the tables in the DataSet
		DataView objDataView = new DataView();

		// get the default view of the Books table into the DataView object
		objDataView = objDataSet.Tables["Books"].DefaultView;
		// and bind it to the third DataGrid on the page
		dgrBooksData.DataSource = objDataView;
		dgrBooksData.DataBind();

		// then do the same for the Authors table
		objDataView = objDataSet.Tables["Authors"].DefaultView;
		dgrAuthorsData.DataSource = objDataView;
		dgrAuthorsData.DataBind();

		// and finally do the same for the Prices table
		objDataView = objDataSet.Tables["Prices"].DefaultView;
		dgrPricesData.DataSource = objDataView;
		dgrPricesData.DataBind();

	}
	
</script>


<!--------------------------------------------------------------------------->
<!-- #include file="..\global\foot.inc" -->
</body>
</html>

⌨️ 快捷键说明

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