From the start of the project to the end of the project, the time spent on this project is half a month. In this case, I will repeat the big examples mentioned in the video. The process is very valuable, in this video, I learned about html controls and Web controls, the advantages and disadvantages of using dynamic controls and static controls, and the differences and connections between these two controls, later, we learned a lot of specific controls in combination with examples. In fact, they are similar to the ones we used before. There are also a few that we have never touched before, what impressed me most is that the six verification controls are very convenient and common, and there are three data controls. Here, the teacher also helped us review ADO. net knowledge is still very familiar. In short, I learned this part of knowledge without adding extra pressure to myself and learning happily. Why is this not a good situation.
I have summarized the Six verification controls mentioned above in the learning process. For details, see:
Http: // http://rong1224017082.blog.163.com/blog/static/186302404201371912931158
Next I will analyze the three template controls mentioned above, which belong to Web server controls, repeater, datalist and DataGrid respectively.
1.What is a template control?
A: A template is a set of HTML elements and controls that form the layout of a specific part of the control, consisting of HTML and embedded server controls. When a control is running on an ASP. NET webpage, the control infrastructure displays the content of the template, rather than the default HTML of the control. To put it bluntly, they are equivalent to the datagridview control that we often use to display data in VB.net.
2.So why should we use the template control?
I said it was for convenience. In this way, you may not be able to agree with my answers. Next, let me explain how troublesome it is to avoid using templates. You are familiar with response. Write (), so let's take a look at how to display the content in the database in a table through this method? We need to output a <Table> label and start the loop. Each time a record is output in a loop, A <tr> tag and several pairs of <TD> and </tr> tags must be output first. End with a </table> label. Is this very troublesome?
ASP. NET has helped us prepare three web server controls to easily display data in the database. Next, I will find their similarities and differences through comparison. In this way, you can easily understand and use them.
3. Commonalities:
Resolution:
1. Although both of them can display data through the template, datalist and reperter must use the template, and DataGrid can also display only one column using the template through the templatecolumn;
2. There are several data source attributes. We are familiar with dataset, sqldatareader, and arrays;
3. as we mentioned above, it still requires a loop to display data through tables, so we don't have to worry about it here. The databind () method will help us solve it, it traverses records in a specific datasource, creates an entry for each record, and corresponds to the item set of the Data Control. Each entry in the data control becomes an instance of a class. This category varies with data controls. For example, the entries in the DataGrid are an instance of the datagriditem class, and the entries in the reperter are an instance of the repeateritem class.
4. We will compare these three controls in three aspects from some perspectives.
A. performance:
The result is that the viewstate generated by the DataGrid is very large, especially when the DataGrid contains many rows.
B. View availability:
Shown in:
1. datalist is the most flexible in customizing data output styles. By setting the repeatcolumn attribute, you can set the number of records displayed in a row. Further, you can even specify that the content of the datlist is not displayed in the table, but in the <span> label, this can be achieved by setting the repearlayout attribute;
2. by setting the allowsorting attribute to true and adding a small amount of code, the DataGrid provides the function of sorting by different fields. The paging and single record editing functions can also be solved by setting the attribute, however, it can only be an HTML table, which is a huge defect and rigid;
3. The lack of repeater in formatting settings directly reflects the extended development time, and its support for internal creation functions (paging, sorting, and editing) is insufficient.
C. From the perspective of development time:
Shown in:
1. The paging and sorting functions in datalist need to be implemented through clever programming, which requires some development time;
2. The DataGrid supports paging and sorting by setting properties;
3. The lack of repeater in formatting settings directly reflects the extended development time
5. When will these three controls be the easiest to use?
If you want to sort, edit, or update data records, use the DataGrid When deleting them. If you want to develop a special data output style, select datalist; if you don't have any concerns about how to display data, you can use repeater with confidence.
After selecting appropriate controls based on your needs, you need to study the specific implementation of the control. It is better to practice it. Come on, comrades, in the next article, I will summarize the differences and connections between HTML controls and Web controls mentioned above. I hope you can provide valuable suggestions.