TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P14

Professional Special Edition- P14:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | For the three tables within the DataSet we assign the DataView object returned by the DefaultView property of the tables to the remaining three DataGrid controls Books .DefaultView Authors .DefaultView Prices .DefaultView A User Control That Returns a DataSet Object The code we ve just seen is used in several examples in this and subsequent chapters and to make it easier we ve encapsulated it as a user control that returns a fully populated DataSet. We need to change the page s file extension to .ascx and change the Page directive to a Control directive @Control Language VB Then instead of placing the code in the Page_Load event handler we place it in a Public Function to which we provide the connection string and the WHERE clause for the SQL statement as parameters. The function returns a DataSet object Public Function BooksDataSet strConnect As String strWhere As String As DataSet strSelectBooks SELECT FROM BookList WHERE strWhere strSelectAuthors SELECT FROM BookAuthors WHERE strWhere strSelectPrices SELECT FROM BookPrices WHERE strWhere Dim objDataSet As New DataSet . code to fill DataSet as before . Return objDataSet End Function Note that this allows us to select a different set of books by varying the strWhere parameter value when we use the control. The example page named Using a control that creates and returns a DataSet object contains the Register directive and matching element to insert the control into the page @ Register TagPrefix wrox TagName getdataset Src . global wrox getdataset id ctlDataSet runat server Then to get a DataSet from the control we just have to create a variable of the correct type and set it to the result of the .

7    6    0    13-08-2020
96    3    0    13-08-2020
41    5    0    13-08-2020
67    7    0    13-08-2020
30    5    0    13-08-2020
1    9    0    13-08-2020
19    16    0
182    15    0
138    6    0
3    7    0
142    12    0