DataGrid Web Control Deep Adventures (1)

zhaozj2021-02-16  49

DataGrid Web Control Deep Adventures (1)

This article is a series of first part of the DataGrid Web Control Article. ASP.NET DATAGRID WEB control can display database information in the HTML table and powerful. In the simplest case, the DataGrid displays the HTML table frame, but it can be enhanced to display a rich user interface, can be sorted according to the columns of the database, or even page the database results! All of these interesting topics will be involved in a series of articles in the future.

Get the table information from the database and display it in an HTML table is one of the most common tasks in the traditional ASP programming. The above functions need to be implemented by multi-line interleaving HTML and code in traditional ASP programming. The original code below shows the usual forms of these code.

CREATE DATABASE CONNECTION

Populate a recordset based on Some SQL Query

Output the html table header (

)

Loop through the recordset

Emit the HTML for a Table Row

...

Emit the html table footer ()

If you are an ASP developer, you may write the above code multiple times. One of the advantages of ASP.NET is that it contains a lot of web controls. These HTML web controls provide a programmable interface that allows developers to separate code and content, and generate HTML entities as objects in the code. That is, if we need to display some HTML content via ASP.NET, the following code will be written: