This is the third article about using the DataGrid Web control. The ASP. Net DataGrid Web control can display database information in HTML tables with powerful functions. In the first article, we discussed the basic functions of the DataGrid. In the second article, we discussed how to set the Display attribute of the DataGrid. This article will study how to associate events with the DataGrid.
Introduction
In the first article, we studied the basic functions of the DataGrid (it is an ASP designed to display data in HTML table labels.. Net Web control. net page shows how simple the database content is. In the second article, we studied how to customize the display of the DataGrid. As we can see in the previous Demo, we can use a small amount of program code to display database information in an impressive format.
Although the displayed data is very effective, what is really useful is whether some form of action can be linked with the DataGrid. For example, imagine that you are working for an e-commerce company and are asked to display all order information through the DataGrid. Each order contains a lot of relevant data, including the purchased goods, order time, purchaser's information (name, address, etc.), and the shipping method selected by the purchaser. Displaying all this information in a DataGrid (for each order) results in excessive information display.
As we can see in the DataGrid Web control deep Adventure (2), we can set the AutoGenerateColumns attribute to False, and then specify the Columns to be displayed through the Columns attribute. Although this method makes the data easy to understand, if the user wants to view the complex details of any order at the same time, what should he do? Ideally, we want to have a button marked as Detail on each row of the DataGrid. When you click this button, all information about the order will be displayed.
The example in this article will lead the reader to create a very similar application. In the previous demonstration, we showed the top 10 frequently asked questions of ASPFAQs.com. This article will expand the demo to display the most critical information about 10 common problems, and each line contains a Detail button.
Build Foundation
In the second article, we mentioned that the DataGrid control allows some BoundColumn tags to be placed in the Columns tag of the DataGrid. Recall that each BoundColumn tag represents a column in The DataGrid. To place buttons in the DataGrid, we can use the ButtonColumn tag, which is similar to the use of the BoundColumn tag. The following code shows how to place buttons in the DataGrid:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.