Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu Binding Data to a Web Forms DataGrid ppt
MIỄN PHÍ
Số trang
5
Kích thước
28.4 KB
Định dạng
PDF
Lượt xem
1703

Tài liệu Binding Data to a Web Forms DataGrid ppt

Nội dung xem thử

Mô tả chi tiết

[ Team LiB ]

Recipe 7.4 Binding Data to a Web Forms DataGrid

Problem

You want to bind the result set from a query to a DataGrid control.

Solution

Set the advanced properties of the DataGrid as demonstrated in the code for the Web

Forms page as shown in Example 7-7.

Example 7-7. File: ADOCookbookCS0704.aspx

<asp:DataGrid id="dataGrid"

style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 56px"

runat="server" AllowPaging="True" AllowSorting="True">

<AlternatingItemStyle BackColor="#FFFF99"></AlternatingItemStyle>

</asp:DataGrid>

The code-behind file contains three event handlers and one method:

Page.Load

Calls the CreateDataSource( ) method and binds data to the Web Forms DataGrid,

if the page is being loaded for the first time.

CreateDataSource( )

This method fills a DataTable with the Orders table from the Northwind sample

database and stores the DataTable to a Session variable to cache the data source

for the DataGrid.

DataGrid.PageIndexChanged

Gets the cached data from the Session variable, updates the CurrentPageIndex of

the DataGrid, and binds the data to the grid.

DataGrid.SortCommand

Gets the cached data from the Session variable, sets the sort order of the default

DataView for the data, and binds that DataView to the grid.

Tải ngay đi em, còn do dự, trời tối mất!