asp+| Data | database | grammar/*
Article Source: http://www.aspCool.com reprint Please specify, thank you!
* * list, data and data bar set
Asp+ provides us with a set of data tables and lists of data controls. These controls can help us customize our UI (user interFace) without considering a database or other database. For example, in the following example, we will describe how the <asp:datagrid runat=server> control provides data to us through SQL statements.
<%@ Import namespace= "System.Data"%>
<%@ Import namespace= "System.Data.SQL"%>
<link rel= "stylesheet" href= "Intro.css" >
<script language= "VB" runat=server>
Sub SubmitBtn_Click (Sender as Object, E as EventArgs)
Dim DS as DataSet
Dim MyConnection as SqlConnection
Dim MyCommand as Sqldatasetcommand
' The following is a database connection
MyConnection = New SqlConnection ("server=localhost;uid=sa;pwd=;d atabase=pubs")
mycommand = New Sqldatasetcommand ("select * from Titles where type= '" + Category.SelectedItem.Value + "", MyConnection)
DS = new DataSet ()
Mycommand.filldataset (DS, "Titles")
Mylist.datasource = DS. Tables ("Titles"). DefaultView
Mylist.databind ()
End Sub
</script>
<body>
<center>
<form action= "intro75.aspx" method= "POST" runat= "Server" >
<asp:adrotator advertisementfile= "Ads.xml" bordercolor= "Black" borderwidth=1 runat= "Server"/>
Category: <asp:dropdownlist id= "Category" runat=server>
<asp:listitem >psychology</asp:listitem>
<asp:listitem >business</asp:listitem>
<asp:listitem >popular_comp</asp:listitem>
</asp:dropdownlist>
<asp:button type=submit text= "Lookup" onclick= "SubmitBtn_Click" runat= "Server"/>
<p>
<asp:datagrid id= "MyList" headerstyle-backcolor= "#aaaadd" backcolor= "#ccccff" runat= "Server"/>
</form>
</center>
</body>
The running example of this example
Http://tutorial.superexpert.com/quickstart/aspplus/samples/webforms/intro/intro75.aspx
Data Grid Control <asp:datagrid runat=server>
Provides a very simple way to display the results of a data query with a traditional UI section. Asp+ developers can now also pass <asp:datalist runat=server>
To customize the data list display to customize the information
<%@ Import namespace= "System.Data"%>
<%@ Import namespace= "System.Data.SQL"%>
<link rel= "stylesheet" href= "Intro.css" >
<script language= "VB" runat=server>
Sub SubmitBtn_Click (Sender as Object, E as EventArgs)
Dim DS as DataSet
Dim MyConnection as SqlConnection
Dim MyCommand as Sqldatasetcommand
MyConnection = New SqlConnection ("server=localhost;uid=sa;pwd=;d atabase=pubs")
mycommand = New Sqldatasetcommand ("select * from Titles where type= '" + Category.SelectedItem.Value + "", MyConnection)
DS = new DataSet ()
Mycommand.filldataset (DS, "Titles")
Mylist.datasource = DS. Tables ("Titles"). DefaultView
Mylist.databind ()
End Sub
</script>
<body>
<center>
<form action= "intro8.aspx" method= "POST" runat= "Server" >
<asp:adrotator advertisementfile= "Ads.xml" bordercolor= "bla
[1] [2] Next page