Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 156 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
156
Dung lượng
4,74 MB
Nội dung
[...]... highlight any gotchas that are likely to trip you up along the way TheASP.NET2.0Anthology (www.sitepoint.com) Chapter 4 Pushing the Boundaries of the GridView The introduction of the GridView control in ASP.NET2.0 basically sent the DataGrid control to the dustbin of ASP.NET history While the DataGrid served us well in its time, the GridView is the table control of choice now, as it boasts more function... simply by dragging the Categories table to the web form After you do so, delete the Categories grid view that was created by the designer We need only the data source TheASP.NET2.0Anthology (www.sitepoint.com) Pushing the Boundaries of the GridView Switching to Source View, you should see the following additional markup for the new SqlDataSource In the following snippet, I removed the DeleteCommand,... for the following items: Code Samples Code in this book will be displayed using a fixed-width font, like so: TheASP.NET2.0Anthology (www.sitepoint.com) xxi A perfect summer's day It was a lovely day for a walk in the park The birds were singing and the kids were all back at school. If the code may be found in the book’s code archive, the name of the file will appear at the top of the. .. will display From the list headed Bindable properties, choose SelectedValue Then, in the righthand column, select the field to which you want to bind this property—CategoryID—as shown in Figure 4.7 TheASP.NET2.0Anthology (www.sitepoint.com) Pushing the Boundaries of the GridView Figure 4.7 Binding a DropDownList control When we switch to the Source View, we see the updated markup for the CategoryID... Figure 4.2 Figure 4.2 The generated GridView 1 http://www.microsoft.com/downloads/details.aspx?familyid=06616212-0356-46a0-8da2-ee bc53a68034&displaylang=en Order the print version of this book to get all 600 pages! 125 126 TheASP.NET2.0Anthology If you click on the Source tab, you can see the markup that the designer generates In the code below, I removed some of the columns and the commands for updating,... bring up the smart tag for the DropDownList—as shown in Figure 4.5—and select Choose Data Source Figure 4.5 Choosing the data source for the DropDownList Order the print version of this book to get all 600 pages! 129 130 The ASP.NET 2.0 Anthology Select the data source containing the Categories table data (it will still be name by its default filename, SqlDataSource2, unless you’ve renamed it), then select... Bring up the smart tag again and select Edit Columns to display the dialog shown in Figure 4.4 Order the print version of this book to get all 600 pages! 127 128 The ASP.NET 2.0 Anthology Figure 4.4 The Fields dialog We need to convert the CategoryID column from a bound column to a template column Select CategoryID in the Selected fields area, click the Convert this field into a TemplateField link, then... accompany a GridView control You can see that the Products table contains a column called CategoryID, which is a foreign key into another table, namely Categories You’ll notice, however, that at present the CategoryID column requires that the user know the range of available category IDs The ASP.NET 2.0 Anthology (www.sitepoint.com) Pushing the Boundaries of the GridView It would be ideal if we could... The ASP.NET 2.0 Anthology (www.sitepoint.com) Pushing the Boundaries of the GridView Switch back to Design View, and click on the upper right arrow of the GridView to display the GridView’s smart tag Be sure to check Enable Editing, as shown in Fig ure 4.3 Figure 4.3 Enabling editing of the GridView If you compile and run this page, you’ll see the interface shown in Figure... Order the print version of this book to get all 600 pages! 131 132 The ASP.NET 2.0 Anthology We’re now ready to build and run the page again This time, when you click on the Edit link to edit a row in the table, you’ll see a drop-down list of product categories from which you can choose, like the one shown in Figure 4.8 Figure 4.8 Selecting a category via the drop-down Select a category, click the Update . class="bi x0 y0 w1 h0" alt=""
The ASP. NET 2. 0 Anthology
The ASP. NET 2. 0 Anthology
ASP. NET 2. 0 Anthology
The ASP. NET 2. 0 Anthology
The ASP. NET 2. 0 Anthology. . . . . 553
The ASP. NET 2. 0 Anthology
The ASP. NET 2. 0 Anthology
The ASP. NET 2. 0 Anthology
The ASP. NET 2. 0 Anthology
The ASP. NET 2. 0 Anthology
(Sample