TAILIEUCHUNG - ASP.NET 4 Unleased - p 53

Using the GridView Control ” SelectCommand=”SELECT LastName,FirstName FROM Employees” Runat=”server” / ” SelectCommand=”SELECT * FROM Employees WHERE FirstName=@FirstName AND LastName=@LastName” Runat=”server” In Listing , the SelectedDataKey() method retrieves the primary key of the selected employee. The SelectedDataKey() method is used in both of the ControlParameters contained in | 494 CHAPTER 11 Using the GridView Control br style clear both div asp SqlDataSource id srcEmployees ConnectionString ConnectionStrings Employees SelectCommand SELECT LastName FirstName FROM Employees Runat server asp SqlDataSource id srcEmployeeDetails ConnectionString ConnectionStrings Employees SelectCommand SELECT FROM Employees WHERE FirstName @FirstName AND LastName @LastName Runat server SelectParameters asp ControlParameter Name FirstName ControlID grdEmployees PropertyName SelectedDataKey FirstName asp ControlParameter Name LastName ControlID grdEmployees PropertyName SelectedDataKey LastName SelectParameters asp SqlDataSource form body html In Listing the SelectedDataKey method retrieves the primary key of the selected employee. The SelectedDataKey method is used in both of the ControlParameters contained in the second SqlDataSource control. If you use SelectedValue instead of SelectedDataKey you can return only the value of the first data key and not both values. A GridView stores data keys in a collection called the DataKeys collection. This collection is exposed by the GridView control s DataKeys property. You can retrieve the data key associated with any row by using a statement that looks like this Object key 6 .Value From the Library of Wow eBook Gridview Control Fundamentals 495 This statement returns the value of the data key associated with the seventh row in the GridView. Remember that the rows collection is zero-based. If you have assigned multiple data keys to each row you can use a statement that looks like this Object key 6 .Values LastName This statement retrieves the value of the LastName key for the seventh row in the GridView. 11 Sorting Data You can sort the rows rendered by a GridView control by enabling the AllowSorting property. For example the page in Listing illustrates how you can sort the contents of the Movies database table. LISTING @ Page Language C DOCTYPE html

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.