📄 use-dataset-control.aspx
字号:
<%@Page Language="VB"%>
<%@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="vb" runat="server">
Sub Page_Load()
'get connection string from ..\global\connect-strings.ascx user control
Dim strConnect = ctlConnectStrings.OLEDBConnectionString
'create a variable to hold an instance of a DataSet object
Dim objDataSet As DataSet
'get dataset from get-dataset-control.ascx user control
objDataSet = ctlDataSet.BooksDataSet(strConnect, "ISBN LIKE '18610033%'")
If IsNothing(objDataSet) Then Exit Sub
'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
Dim objDataView As 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()
End Sub
</script>
<!--------------------------------------------------------------------------->
<!-- #include file="..\global\foot.inc" -->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -