Feed on
Subscription

Contact ASP.Net(11 intimately)

Inside ASP.Net in,How to accomplish minute of page

I not merely the ground is asked about by others,If why realize the function that distribute a page in ASP.Net.I am not willing to answer this question really.Because minute of page comes true in ASP.Net,It is too simple really,See to you the process can be enraged so that jump simply building,Ah ah should publish plaint,Why this east east come out not early.

Be in with the WEB technology that live in,We should accomplish minute of page,Often be to grow string of code ability to do decide it,And every use a page,Be about to rescript,Irritated a nuisance.But in ASP.Net DataGrid of have the aid of accuses,We divide page program to be able to be done easily calm,Of need just accuse to DataGrid make a few set.We or have the aid of in light of a program:)

%26lt;% @ Page Language= %26quot;C#%26quot; %%26gt;
%26lt;% @ Import Namespace= %26quot;System.Data%26quot; %%26gt;
%26lt;% @ Import Namespace= %26quot;System.Data.ADO%26quot; %%26gt;
%26lt;Script Language= %26quot;C#%26quot; Runat= %26quot;Server%26quot; %26gt;
Public Void Page_Load(Object Src, eventArgs E)
{
/ / coupling statement
String MyConnString = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=c:/test/test.mdb;" ;
String StrComm = "select * From UserList Order By Id" ;

/ / open a tie
ADOConnection MyConnection = New ADOConnection(MyConnString);

/ / open two DataSetCommand
ADODataSetCommand MyComm = New ADODataSetCommand(strComm, myConnection);


DataSet MyDataSet = New DataSet();

/ / UserList, bookList watch stocks DataSet
MyComm.FillDataSet(MyDataSet, "UserList" );


DataGrid1.DataSource = MyDataSet.Tables["UserList" ].DefaultView;
DataGrid1.DataBind();

}
%26lt;/script%26gt;
%26lt;html%26gt;
%26lt;head%26gt;
%26lt;title%26gt;%26lt;/title%26gt;
%26lt;/head%26gt;
%26lt;body%26gt;
%26lt;form Runat= %26quot;server%26quot; %26gt;
%26lt;ASP:DAtaGrid Id= "DataGrid1" Runat= "server "
BorderColor= "black "
BorderWidth= "1 "
GridLines= "Both "
CellPadding= "3 "
CellSpacing= "0 "
Font-Name= "Verdana "
Font-Size= "8pt "
HeaderStyle-BackColor= "#aaaadd "
AlternatingItemStyle-BackColor= "#eeeeee "
/ %26gt;
%26lt;/form%26gt;
%26lt;/body%26gt;
%26lt;/html%26gt;

Its indication eventuate:



Graph 11-1

Everybody can see the 11 data all in this UserList watch came out,Did not distribute a page.

Below we are small change DataGrid to accuse attribute.Add

AllowPaging= "True "
PageSize= "5 "
PagerStyle-HorizontalAlign= "Right "

Look again:


Graph 11-2

Those who see a picture most below,It is much,,This expresses to distribute a page,The circumstance that we go to pressing that label to be able to see below one page:)


Graph 11-4

All these is too simple.Breathe out ah.Their origin is I increased those three property only.Wanted an AllowPaging to go only actually.

AllowPaging is to point to allow to distribute a page,This is the mainest.Had it,We just can distribute a page.

PageSize is the record number that assigns every page to show,If be not written,It is 10 with respect to meeting acquiesce.

PagerStyle-HorizontalAlign is the fixed position that appoints minute of face to show,Acquiesce is Left.

Whole code is:

%26lt;ASP:DAtaGrid Id= "DataGrid1" Runat= "server "
AllowPaging= "True "
PageSize= "5 "
PagerStyle-HorizontalAlign= "Right "
BorderColor= "black "
BorderWidth= "1 "
GridLines= "Both "
CellPadding= "3 "
CellSpacing= "0 "
Font-Name= "Verdana "
Font-Size= "8pt "
HeaderStyle-BackColor= "#aaaadd "
AlternatingItemStyle-BackColor= "#eeeeee "
/ %26gt;
 

It is very simple.Breathe out ah.

When the attention writes this, did not want to forget %26lt;form%26gt; ,Otherwise your page is to be able to show,But cannot break up,Breathe out ah.Because this is need,refer:)

The content with our retell more detailed solution,Breathe out ah,Basically be to consider the picture is too much.The speed that browse can slow.

 

 
Related:

    Submit: