TAILIEUCHUNG - ASP.NET 4 Unleased - p 75

Sử dụng Control QueryExtender Và bạn có thể định nghĩa một phương thức tĩnh trong trang (mặc dù chúng tôi khuyên bạn nên xác định rõ ràng tên kiểu như vậy bạn có thể tránh điền mã của bạn-behinds với logic bổ sung) như sau: | 714 CHAPTER 16 Using the QueryExtender Control And you might define a static method in the page though we recommend explicitly defining the type name so you can avoid filling your code-behinds with additional logic as follows public static IQueryable Product FilterOutPastDueAccounts IQueryable BankAccount query return from account in query where select account The return value from this method is passed down the chain of filter expressions. One great advantage of putting code behind these expressions is that they can be easily reused across multiple pages. This is another reason we recommended specifying the type name of the expression class explicitly rather than putting the expression method in the page s code-behind. Sorting with the OrderByExpression The OrderByExpression provides developers with a way of specifying a sort expression that can be applied to the query within the query extender control. The two properties of the OrderByExpression that control the sorting are the DataField and Direction properties. The DataField property contains the name of the column on which the sorting will take place and the Direction property indicates which direction the sorting will be done. asp QueryExtender runat server TargetControlID AccountsReceivableSource asp OrderByExpression DataField AmountDue Direction Descending asp QueryExtender In the preceding code we sort the accounts receivable rows in descending order by the amount due. This should give us a nice list of the people who owe us money and where they live. This might not be sufficient. What if for example for each dollar amount we want to sort the receivables by the age of the customer This can enable us to see the oldest person that owes us each amount of money. We can use a ThenBy tag as a child of the OrderByExpression to accomplish this as shown below asp QueryExtender runat server TargetControlID AccountsReceivableSource asp OrderByExpression DataField AmountDue .

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.