SQLORACLE Universal Persons Control in ASP.NET

xiaoxiao2021-03-06  25

These days have studied the paging control on MSDN on the Dino Esposito at http://www.microsoft.com/china/msdn/archives/library/dnaspp/html/pagerControls.asp, there is still some problems in the original control: 1 It is only suitable for SQL Server, and it cannot be used for Oracle2. When you choose NonCached paging mode, you will be turned to the last page. 3. When binding to the validated object, the page will result in verification to rewrite the code, add a paging for Oracle, fix the original error, and merge the NUMERIC mode. Still open source code, source code download: http://www.cnblogs.com/files/liubr/webpager.rar Advantages: 1, almost any ASP.NET control 2, the paging efficiency, simple code, specify database connection, You can use the SQL Server database, you can also be used for the SQL Server database, you can also use only the database connection and query statement. 4, two data query: cached and instant mode noncached cached: temporarily store data ASP.NET's cache, take directly from the cache, no longer and database interact with Noncached: only retrieve the current page record, not cached 5, support according to title Sort 6, do not use the stored procedure, support any complex queries, Simple coding. Schedule: WebPager control programming interface

name

Types of

Description

Cachedure

Attributes

Indicates the number of seconds that the data is retained in the cache of ASP.NET. Only used for Cached mode. The default is 60 seconds.

Connectionstring

Attributes

Use to access the connection string of the selected SQL Server / Oracle database.

Controltopaginate

Attributes

The control ID in the same .aspx page, which displays the recording page retrieved by the paging program. This is a partner control.

CurrentPageIndex

Attributes

Get and set 0-based page index.

Itemsperpage

Attributes

Get and set the number of records to display per page. The default is 10 items per page.

Pagerstyle

Attributes

This value indicates the style of the page program user interface. It can enumerate values ​​for Pagerstyle: NEXTPREV and NUMERICPAGES. In the NextPrev mode, the previous page will be displayed to the first page, the next page, the next page and the last page. In the NumericPages mode, only one drop-down list is displayed, and the index of all available pages will be listed.

Pagingmode

Attributes

This value indicates how to retrieve data. It can be enumerated for the PagingMode: Cached and Noncached. If you are cached, a data adapter will be used, and the entire result set will be temporarily placed in the ASP.NET cache, without having to interact with the database each time. If you are Noncached, you only retrieve the records in the current page. In this case, the cache is not performed.

SELECTCOMMAND

Attributes

Command text used to perform queries. It is best to select-from-wherere. The ORDER BY clause is not supported. Sort is additionally specified by the sortfield property.

Sortfield

Attributes

The name of the field used to sort. This field is used to provide dynamic order by clauses for query. Can be separated by a comma between multiple fields. Clearcache

method

Delete any data stored in the ASP.NET cache. For the Cached mode, click on the column header to sort Cache

DataBind

method

Binding data, bind control with other data

How to use: in the ASPX file

<% @ Register tagprefix = "pg" namespace = "devcenter" assembly = "Webpager"%>

...

ID = "SQLPAGER1"

Runat = "server"

Controltopaginate = "DataGrid1" Connectionstring = "Server = localhost; database = northwind; uid = sa; password =;"

SelectCommand = "SELECT CUSTOMERID, CompanyName from Customers" Pagerstyle = "NextPrev"

Pagingmode = "noncached">

(The above attributes can also be written in the background code) background code: SQLPAGER1.CURRENTPAGEINDEX = 0; sqlpager1.database (); To sort the title, in CommandSort code: SQLPAGER1.Sortfield = E .Sortexpression; sqlpager1.database (); Note: 1, when using the Cached mode, due to the data, the data is cached, reordered the data, you need ClearCache () to clear the cache, and then perform data binding, otherwise To wait a cache expired to see the effect. 2. When using the Noncached method in SQLPAGER, if you want to sort the title columns with duplicate data, you may be inaccurate. Rownum columns are regenerated in Oracle, there is no such problem. If there is a column of a unique value, you can add this column in Sortfield. I haven't thought of better ways for this issue. If a good method can be discussed together. The above problem 2: Sorted paging is achieved by sequencing the sorting fields, then re-uses Top N, but the repetition value ASC and DESC have no effect on the sorting results, which is northwind as an example: select ORDERID, EMPLOYEID From Orders WHERE Employeid = 1 Order by Employeeid ASC and Select ORDERID, Employeeid from ORDERS WHERE EMPLOYEEID = 1 Order by Employeeid Desc results are the same, for complex queries, column uncertain, result in the result set may have no primary key, unable to use table variables and temporary Table, I have not thought of better ways to deal with, welcome everyone to discuss

转载请注明原文地址:https://www.9cbs.com/read-65091.html

New Post(0)