Dynamic Data Control in ASP. NET futures CTP has become an ASP. NET Ruby on Rails version-No configuration or needCode, Without any intervention-as long as one control, a complete data-drivenProgramThat's it. The dynamic data control automatically searches for databases in the project and selects a data table with the same file name as the page, automatically provides functions such as list display, detailed content display, filtering, paging, sorting, addition, deletion, editing, modification, and RSS-Yes, all of them are automatic-only one control, you don't even need any settings! Very interesting and extremely useful!
This article will give a brief introduction to dynamic data controls.
ASP. NET futures download, install, and create a new web site
ASP. NET futures can be downloaded here: http://www.asp.net/downloads/futures /. Size of 50 MB
ASP. NET futures Reference document: http://quickstarts.asp.net/Futures/default.aspx
ASP. NET futures official forum: http://forums.asp.net/1127/ShowForum.aspx
After the download is complete, install the MSI. The process is very simple. If the RP is good, there should be no problems.
Open VS 2005, create a web site, and select ASP. NET futures web site:
You can use the default template to create an ASP. NET ures web site. Open its web. config file, analyze it carefully, and add a lot of things.
However, in vs toolbox, you will find more interesting things:
Seeing so many green and green new control icons, is it a bit itchy? But this articleArticleOf course, you cannot introduce all the content, just starting with the Dynamic Data Control Section. If there is time, I will come in a later article.
Use northwind as the example Database
To demonstrate the powerful functions of the Dynamic Data Control, the northwind database is also used here.
By the way, we will introduce how to use the northwind database in SQL express provided by VS 2005, so that it is convenient for users who do not have a database:
First download and install the original northwind database: http://www.microsoft.com/downloads/details.aspx? Familyid = 06616212-0356-46a0-8da2-eebc53a68034 & displaylang = en
In the command line window, navigate to "C: \ SQL Server 2000 sample databases"
Enter the following command (Replace [computer name] With your computer name ):
Osql-e-s [computer name] \ sqlexpress-I instnwnd. SQL
The first time may encounter a timeout failure (rpwt, huh, huh), but try again.
Implementation Sample Page
We will display the data in the Employees table in the northwind database.
First. add the connection string of the SQL Express version of the northwind database in config (you can modify it as needed to connect to other databases, but this is not covered in this article ), in this way, the dynamic data control can know the data in the database to be displayed:
<Connectionstrings>
<Add Name= "Northwindconnectionstring1"
Connectionstring= "Data Source = DFLYING-LAPTOP; initial catalog = northwind; Integrated Security = true"
Providername= "System. Data. sqlclient" />
</Connectionstrings>
Create a new page named "employees. aspx". You must use this name so that the dynamic data control can know which table (Employees table) in the database to display )! Add a dynamicautodata control to employees. aspx:
<ASP: dynamicautodata ID= "Dynamicautodata1" Runat= "Server" />
The dynamicautodata control is one of the many dynamic data controls and the most comprehensive one (very suitable for example programs to attract attention, ).
Then ............
............
............
............
............
............
............
............
............
............
............
............
............
No! It's really gone! If you don't believe it, check whether employees. aspx is complete.Source code:
<% @ Page Language = "C #" %>
<!Doctype Html Public "-// W3C // dtd xhtml 1.0 transitional // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html Xmlns= "Http://www.w3.org/1999/xhtml" >
<Head Runat= "Server">
<Title>Northwind employees</Title>
<Style Type= "Text/CSS">
* {Font: 11px tahoma ;}
</Style>
</Head>
<Body>
<Form ID= "Form1" Runat= "Server">
<Div>
<ASP: dynamicautodata ID= "Dynamicautodata1" Runat= "Server" />
</Div>
</Form>
</Body>
</Html>
Amazing results of a line of code
What is the name of the dynamicautodata control in this row? Run F5. I really don't know ...... (Sorry, the figure is a little big. It's really too many functions ...... I didn't mean it)
Let's take a closer look at what functions are available:
Gridview list
RSS:
Filter:
Edit:
(The drop-down list box is also available ):
Sort:
View the relationship between entries (employee's boss and employee's subordinates ):
Employee details (handsome guy ):
Add new employee:
This is just a code implementation ...... Ror is born!
Source code download
The source code of this instance program is downloaded here: http://files.cnblogs.com/dflying/DynamicAutoData.zip