DataGrid, DataList, and Repeater are the three most commonly used controls in ASP. NET. The following describes the transformation from traditional ASP to ASP. NET: What are the defects of traditional ASP and how ASP. NET solves these problems based on the considerations.
Traditional ASP Problems
Since the emergence of simple and script-based Web programming technology such as Microsoft Active Server Pages (ASP), Web development has experienced great development. A lot of tedious and repetitive coding work in traditional ASP does not exist in Microsoft ASP. NET. For example, as all traditional ASP developers once knew, displaying data on traditional ASP Web pages requires the following pseudo code:
- Create connection to the database
- Populate an ADO Recordset with a SQL query
-
- Display any header HTML needed
- For Each Record in the Recordset
- Print out the Recordset field(s) and associated HTML
- Move to the next record
- Next
- Display any footer HTML needed
For example
<Table>
The record set content is displayed, and developers have
<Table>
Tags generate HTML tags, and then traverse each record in the record set cyclically.
<Tr>
Tag, and many
<Td>
The value of the tag and the record set field to be displayed. Finally, after the loop, the developer needs to generate the end
<Table>
Mark.
This method, which is required by traditional ASP, has a major drawback: it closely integrates HTML content with the source code of ASP Web pages. Because code and HTML content are not separated, it is difficult to modify HTML content, especially for graphic artists or Web designers who do not understand programming technology. Besides, because code is required to retrieve database results and generate content, this integration of code and HTML content requires a large amount of code.
Traditional ASP to ASP. NET: Control Introduction
Fortunately, ASP. NET provides three controls, making it easier to display data on ASP. NET Web pages than traditional ASP requires for iterative methods. These three controls are DataGrid, DataList, and Repeater, which I will call a Data Web control later. Maybe, if you have developed an ASP. NET Web page, you will have at least some experience with one of the three controls. Generally, developers start learning the DataGrid because it is easy to use and has the ability to allow data sorting, paging, and editing. However, when the data is displayed on the ASP. NET Web page, the DataGrid is not always the best choice for the control.
In the following section, we will study the unique features of each control in these data Web controls. These features give each data Web control many advantages and disadvantages. Because every data Web control has some disadvantages, there is no "perfect" control that can be used for any job. When deciding which control to use, you must weigh the advantages and disadvantages of each of the three data Web controls, and then decide which control is the most suitable.
To assist in the comparison, when studying every data Web control, we will focus on these three metrics: availability from the perspective of Web visitors), development time and performance. First, let's take a quick look at the similarity between the three data Web controls. Next we will study the DataGrid in depth, study DataList, and finally view Repeater. For each control, we will study the functions of these controls and discuss how their feature set affects these metrics.
The above briefly introduces the transformation from traditional ASP to ASP. NET.
- How to use ASP. NET to debug APIs
- Five methods for generating HTML static pages using ASP. NET templates
- How to Use the ASP. NET Login Control
- What is ASP. net mvc and its advantages
- Differences between ASP. net mvc and WebForm