Some discussions in DataGrid, DataList or Repeater (1)

xiaoxiao2021-03-05  23

Web development has experienced a long process since the scripting-based Web programming technology (such as ASP) has experienced a long process. By using Microsoft's ASP.NET technology, there are a large amount of ASP, and the programming of monotonous, repetitive programming work is historical. For example, like most ASP programmers, the process required to display database content in the ASP: Creating a database connection SQL query load ADO dataset display The record output record field value of any HTML code required to traverse data sets and Related HTML Moves Next Record Cycle Display The required HTML code is as follows, in order to display the contents of the record set in the table, we need to output one

Label and start cycling. In the loop, each output is output, you need to output one

Label and a number of pairs

Labels and labels. Finally, in one

The label ends. This method used in traditional ASP has a major disadvantage: HTML code has to be entangled with ASP source code. For those page designers or graphic artists who may not understand the program design, it is undoubtedly a disaster for changing HTML. In addition, the amount of code is also amazing, because we not only need to obtain data from the database, but also need to be visualized. Ok, ASP.NET provides three data controls that make it easy to work in complicated in ASP. These three controls are data web controls, which are DataGrid, DataList, and Repeater. If you have aware of the ASP.NET database programming, you should at least have experience in using one of the controls. In most cases, we start using DataGrid from learning because it's relatively complete (data display, paging, editing) and relatively simple. However, DataGrid is not always the correct choice. This article will discuss the characteristics of each data control different from other data controls, respectively, and the advantages and disadvantages of this. It is precisely because each data control has its own defect, so there is no perfect choice in programming. You must weigh the advantages and disadvantages of the three controls and determine which one is more suitable for you. To help comparison, we will focus on three characteristics: availability (from the perspective of page visits), development time and performance. We first describe the commonality of these three controls, and then discuss the characteristics of three controls, how each control is implemented and how to reflect availability, development time and performance. [Community of Data Web Controls] It is necessary to see the commonality between them before we discuss the individual features of the three controls. In general, from the programming process, the most pronounced common point is that these three controls are used to display data. Another common point is a code that requires a data binding code to bind the data to the control. This process only needs two lines of code: DataWebControlID.DataSource = SomeDataSource DataWebControlID.Database, SOMEDASOURCE object refers to data source properties of the data control, which can be DataSet, SqldataReader, OLEDBDataReader or a set of data (such as arrays, array lists) Or other class belonging to the SYSTEM.COLLECTION name space). However, objects that implement the IENUMERABLE interface can also be bound to the data control. The database traverses a record in a specific DataSource and establishes an entry and corresponds to the ITEM set of the data control. Each entry in the data control will become an instance of a class. This class is different from the different data controls. For example, each entry in the DataGrid is an instance of the DataGridItem class, and the entry in the Repeater is an instance of the REPEATERITEM class. The reason why different categories to instantiate different data controls is because different data controls will display data and corresponding HTML code in different ways. For example, the DataGridItem class inherits from the TableRow class, that is, every DataGridItem's instance can be seen as a line in a table. This is because DataGrid is designed to use HTML

转载请注明原文地址:https://www.9cbs.com/read-37992.html

New Post(0)