In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
How to understand the pros and cons of data binding controls commonly used in ASP.NET? I believe that many inexperienced people do not know what to do about it. Therefore, this paper summarizes the causes and solutions of the problems. Through this article, I hope you can solve this problem.
Because most of these data-bound controls are well encapsulated, friends with a little foundation can easily use them, so this article does not involve the use of specific controls, but only analyzes their respective advantages and disadvantages, but in the next article, I will mainly talk about the "efficient paging" of the three data-bound controls, ListBox, GridView and Repeater. ListBox and GridView have built-in paging, but their efficiency is too low. A small amount of data is OK, a large amount of data can not be used at all, the Repeater control itself does not provide paging, but in actual development may also be useful to paging, so I will also tell you about the paging of Repeater.
All right, now let's get down to business, starting with the more commonly used controls.
1. GridView control
Main features: support deletion, modification, sorting, paging, appearance settings, custom display data
Missing points: affect program performance, do not support insert operations
This control can display, edit, and delete data from a variety of different data sources (such as databases, XML files, collections, etc.) in tabular form (table tags). The GridView control is so powerful that programmers can drag and drop through VS 2008 without writing any code, set properties from the properties panel, and complete functions such as paging, sorting, appearance settings, and so on. Although the functionality is very complete, the performance of the program will be affected, and it is best not to use this control too much on the page. Of course, if you need to customize the format to display a variety of data, the GridView control also provides template functionality for editing formats, but does not support data insertion.
The figure shows:
2. ListView control
Main features: provide add, delete, change, sort, paging and other functions, but also support user-defined templates
Deficiency: affect program performance, big data's paging efficiency is low.
The ListView control displays data in a template format written by the programmer. Like the DataList and Repeater controls, the ListView control applies to any data that has a duplicate structure. However, the ListView control provides data manipulation functions such as editing, inserting and deleting data, as well as sorting and paging the data, which only needs to be set up directly in VS 2008 without writing code, which is very similar to the GridView control. It can be said that ListView not only has the open template of Repeater control, but also has the editing feature of GridView control. ListView control is a new control in ASP.NET 3.5, and its paging function needs to be realized with DataPager control. ListView control is a new control in ASP.NET 3.5, and its paging function needs to be realized with DataPager control. But for a large amount of data, the paging efficiency is very low, so in the next section, I will lead you to do an efficient paging. Overall, ListView is by far the most versatile and best-used data-bound control.
As shown in the figure:
3. Repeater control
Main advantages: this control is a complete development control, which can display user-defined display mode freely.
Missing points: do not support paging, sorting, editing, only provide duplicate template content
The Repeater control is a data-bound container control that generates a list of children that can be displayed entirely by the programmer. When the page where the control is running, the control repeats the data display format defined in the template according to the number of data rows in the data source, and the programmer can fully grasp the display layout of the data, such as using div elements, ul elements, and so on. But the only drawback is that the control does not support functions such as sorting, paging, editing, and so on, and only supports the function of repeating template content, but in actual development it may be useful for functions such as paging, so in the next section, I will focus on Repeater paging.
As shown in the figure:
4. DataList control
Main advantages: can customize the format to display data, more flexible
Missing points: paging, editing and insertion are not supported
The control can display fields from various data sources in a custom format, the format of the display data is defined in the templates created, and templates can be created for items, alternating items, selected items, and editing items. The DataList control can also customize the overall appearance using title, footer, and delimiter templates, and can display multiple rows of data in a row. Although the DataList control has great flexibility, it does not support data paging itself, and programmers need to complete the paging function through their own writing methods. It is only used for the display of data, and editing, insertion and deletion are not supported.
As shown in the figure:
5. DetailsView control
Main advantages: display individual data in tabular form, support sorting, insertion, deletion, modification, paging
Missing point: sorting is not supported
The DetailsView control displays only a single record of the data source at a time in tabular form (table tag), and each row (tr tag) under the table tag represents a field in the record. This control also supports editing, inserting, and deleting data, and can easily set paging, but the DetailsView control itself does not support data sorting.
As shown in the figure:
6. FormView control
Main advantages: display single data, paging, add, delete, change, customizable template display
Missing point: sorting is not supported
Functionally, the FormView control is very similar to the DetailsView control, and the FormView control can only display a single record in the data source. Unlike the DetailsView control, the DetailsView control uses a table layout (table label), and each field of the record is displayed as a row. While the FormView control does not have a preset layout for displaying records, programmers need to create their own subitem templates, write various controls for displaying fields in the record, and other HTML tags for layout. Like the DetailsView control, the FormView control can easily enable paging. If you only display a single record, the FormView control is the recommended method, because you can customize the format of the data display while developing efficiently.
As shown in the figure:
7. DropDownList control
Main advantages: mostly used for multi-stage linkage
Missing points: as much as one field can be displayed
DropDownList controls are generally used for multi-level linkage, such as the linkage of provinces and cities. Here we mainly talk about the key points, that is, to set the fields and value display fields to be displayed for DropDownList, namely:
The result of binding is as follows:
So far, we have analyzed the advantages and disadvantages of the data-bound controls commonly used in Asp.net. Only by deeply understanding the characteristics of each control, can we better adopt appropriate controls under appropriate circumstances and better promote program development. Of course, it is possible that in the actual development process, we will not use these controls, after the packaging of Microsoft to generate too much additional information, increasing the pressure on the server.
After reading the above, have you mastered how to understand the pros and cons of common data-bound controls in ASP.NET? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.