|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
不可能天天有学习.net),我一同学说,你应该早就有作品啦。我惶惶然……这是我写的一个分页控件,功效以下:
1.撑持计划时撑持和两种分页形式,个中综合分页形式的效果以下:
一般分页形式的效果以下:
2.完美的计划时撑持,包含主动套用格局和计划时面板设置:
利用办法:
在aspx页面中:
复制代码代码以下:
<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="Default.aspx.cs"Inherits="Cyclone.CustomPager.WebApplication._Default"%>
<%@Registerassembly="Cyclone.CustomPager.Pager"namespace="Cyclone.CustomPager.Pager"tagprefix="Cyclone"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title></title>
<linktype="text/CSS"rel="stylesheet"href="style/comm.css"/>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:GridViewID="GridView1"runat="server"AllowPaging="false"AutoGenerateColumns="False"CellPadding="4"ForeColor="#333333"GridLines="None"PagerSettings-Visible="false"
Width="80%"height="35"DataKeyNames="ID">
<FooterStyleBackColor="#507CD1"Font-Bold="True"ForeColor="White"/>
<RowStyleBackColor="#EFF3FB"/>
<EditRowStyleBackColor="#2461BF"/>
<SelectedRowStyleBackColor="#D1DDF1"Font-Bold="True"ForeColor="#333333"/>
<PagerStyleForeColor="White"VerticalAlign="Top"BackColor="Transparent"/>
<HeaderStyleBackColor="#507CD1"Font-Bold="True"ForeColor="White"/>
<AlternatingRowStyleBackColor="White"/>
<Columns>
<asp:TemplateFieldHeaderText="序号">
<ItemTemplate>
<%#Container.DataItemIndex+1%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundFieldDataField="ID"HeaderText="用户ID"/>
<asp:BoundFieldDataField="UserName"HeaderText="用户名"/>
<asp:BoundFieldDataField="Email"HeaderText="Email"/>
<asp:BoundFieldDataField="Address"HeaderText="地点"/>
</Columns>
</asp:GridView>
</div>
<div>
<Cyclone:AspNetPagerID="AspNetPager1"runat="server"ButtonText="GO"EndPageText="末页"
FirstPageText="首页"NextPageText="下一页"PageSize="15"PrePageText="上一页"OnPageChanged="Page_Changed"Width="80%"PageMode=NormalBackColor="#FFE0C0"BorderColor="#FFC0C0"BorderStyle="Solid"BorderWidth="1px"ForeColor="#804040">
<ButtonStyleCssClass="btn1_mou搜索引擎优化ut"Width="30px"/>
<TextBoxStyleWidth="30px"CssClass="blue_rounded"/>
<LabelStyleForeColor="Red"Font-Bold="True"/>
</Cyclone:AspNetPager>
</div>
</form>
</body>
</html>
在背景代码中:
复制代码代码以下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Data;
namespaceCyclone.CustomPager.WebApplication
{
publicpartialclass_Default:System.Web.UI.Page
{
privateList<User>_data=newList<User>();
protectedoverridevoidOnInit(EventArgse)
{
base.OnInit(e);
this.GetData();
}
protectedvoidPage_Load(objectsender,EventArgse)
{
if(!Page.IsPostBack)
{
BindData();
this.AspNetPager1.PageIndex=1;
}
}
privatevoidGetData()
{
for(inti=0;i<1000;i++)
{
this._data.Add(newUser{ID=i+1,Address="北京市海淀区",Email="mickjacksonfeng@163.com",UserName="凭海不雅澜"});
}
}
protectedvoidPage_Changed(objectsender,EventArgse)
{
BindData();
}
#region绑定试卷界说计划列表
///<summary>
///依据以后页码查询必要的数据
///</summary>
///<paramname="pageIndex">页码</param>
privatevoidBindData()
{
this.AspNetPager1.RecordCount=this._data.Count;
List<User>users=this._data.Skip(this.AspNetPager1.PageSize*(this.AspNetPager1.PageIndex-1)).Take(this.AspNetPager1.PageSize).ToList();
GridView1.DataSource=users;
GridView1.DataBind();
}
#endregion
}
publicclassUser
{
publicintID{get;set;}
publicstringUserName{get;set;}
publicstringEmail{get;set;}
publicstringAddress{get;set;}
}
}
别的:
天职页控件还包括复杂属性,庞大属性,自界说视图形态,分页事务,创立控件,render控件,Attribute,计划时撑持等对照完全的自界说控件的元素,是个不错进修自界说控件开辟的例子,具体代码能够到上面举行下载:剧本之家下载地点
不可能天天有学习.net),我一同学说,你应该早就有作品啦。我惶惶然…… |
|