DataGrid Web Control Depth Adventures (3) Part1

zhaozj2021-02-16  59

This article is a series of third articles on the use of the DataGrid Web Control. ASP.NET DATAGRID WEB control can display database information in the HTML table and powerful. In the first article we discussed the basic functions of DataGrid; in the second article we discussed the information of setting the DataGrid display attribute. This article will study how to link events to DataGrid.

preface

In the first article, we studied the basic functions of DataGrid (it is an ASP.NET web control designed to display data in the HTML table label), showing how the database content is displayed through the ASP.NET page. . In a second article we studied how to customize the display of DataGrid. As seen in the previous demo (Demo), we can display database information in an impressive format through very few program code.

Although the display data is very effective, it is really useful to link some form of action with the DataGrid. For example, imagine that you are working for an e-commerce company and asked to display all order information via DataGrid. Each order contains a lot of related data, including ordered goods, ordering time, information (name, address, etc.), and the shipping method selected by the purchaser. Displaying all of this information will result in excessive information display in a DataGrid (for each order).

As seen in the DataGrid Web Control Depth Adventures (2), we can specify the columns you want to display by setting the AutoGenerateColumns property to false and then specify the columns you want to display by using the columns property. Although this practice makes the data easy to understand, if users want to view the complex details of any order, what should I do? Ideally we hope that there is a button marked as detail on each line of DataGrid, and all information will be displayed after clicking this button.

The examples of this article will lead the reader to create a very similar application. In the previous demonstration we showed 10 common problems of Aspfaqs.com. This article will expand the presentation to display the most critical information of 10 common problems, while each line contains a Detail button.

Construction foundation

We mentioned that the DataGrid control allows the DataGrid control to allow some BoundColumn tags in the DataGrid ColumNS tag. Recall that every BoundColumn tag represents a column in the DataGrid. In order to place the button in the DataGrid, we can use the ButtonColumn tag, which is similar to the Usage of the BoundColumn tag. The following code shows how to place the button in the DataGrid:

< / ask: DataGrid> The example running results are as follows: Contains the DataGrid of the button

This example shows a DataGrid web control containing the Detail button. The button is displayed in the form of a link; if you want the link to become a standard button, you need to enter buttype = "pushbutton" in the ButtonColumn tag.

FAQ DETAILS

FAQ ID

FAQ DESCRIPTION

Details

144

WHERE CAN I HOST MY ASP Web Site for Free (SIMILAR TO Geocities or tripod or any of the many Other Free Web Site Sites)?

Details

181

How can I Format NumBers and Date / Times Using ASP.NET? For Example, I Want To Format A Number As a Currency.

...

Source code:

<% @Import namespace = "system.data"%> <% @Import namespace = "system.data.sqlclient"%>