|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我见过java运行在手机上,包括很廉价的山寨手机,但是却暂时没发现.net在手机上有什么作为。wp7可能是个转机,但是按照《Java的跨平台就是一句谎言。那.net的跨平台也当之无愧是一句谎言。复制代码代码以下:
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Test(Datalist数字分页).aspx.cs"Inherits="Test_Datalist数字分页_"%>
<!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>
<linkhref="CSS/CSS.css"rel="stylesheet"type="text/css"/>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:DataListID="DataList1"runat="server">
<ItemTemplate>
<asp:LabelID="Label1"runat="server"Text=<%#Eval("mid")%>></asp:Label>
</ItemTemplate>
</asp:DataList>
</div>
<br/>
<divid="PageInfo"runat="server"class="LPageBar"></div>
</form>
</body>
</html>
CS代码:
复制代码代码以下:
usingSystem;
usingSystem.Collections;
usingSystem.Configuration;
usingSystem.Data;
usingSystem.Linq;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.HtmlControls;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Xml.Linq;
publicpartialclassTest_Datalist数字分页_:System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
//ComFunctioncf=newComFunction();
//DataSetds=cf.DataBind("M_dizhi");
//this.PageInfo.InnerHtml=PageNums.GetPageNum(ds,DataList1,12);
this.PageInfo.InnerHtml=PageNums.GetPageSql("M_dizhi",DataList1,12);
}
}
PageNums.cs
复制代码代码以下:
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.HtmlControls;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Data.SqlClient;
///<summary>
///PageNums的择要申明
///</summary>
publicclassPageNums
{
///</summary>
///<paramname="ds">DataSet实例</param>
///<paramname="datalistname">DataList称号</param>
///<paramname="pagesize">分页巨细</param>
publicstaticstringGetPageNum(DataSetds,DataListdatalistname,intpagesize)
{
PagedDataSourceobjPds=newPagedDataSource();
objPds.DataSource=ds.Tables[0].DefaultView;
objPds.AllowPaging=true;
inttotal=ds.Tables[0].Rows.Count;
objPds.PageSize=pagesize;
intpage;
if(HttpContext.Current.Request.QueryString["page"]!=null)
page=Convert.ToInt32(HttpContext.Current.Request.QueryString["page"]);
else
page=1;
objPds.CurrentPageIndex=page-1;
datalistname.DataSource=objPds;
datalistname.DataBind();
intallpage=0;
intnext=0;
intpre=0;
intstartcount=0;
intendcount=0;
stringpagestr="";
if(page<1){page=1;}
//盘算总页数
if(pagesize!=0)
{
allpage=(total/pagesize);//盘算总页数
allpage=((total%pagesize)!=0?allpage+1:allpage);
allpage=(allpage==0?1:allpage);
}
next=page+1;
pre=page-1;
startcount=(page+5)>allpage?allpage-9:page-4;//两头页肇端序号
//两头页停止序号
endcount=page<5?10:page+5;
if(startcount<1){startcount=1;}//为了不输入的时分发生正数,设置假如小于1就从序号1入手下手
if(allpage<endcount){endcount=allpage;}//页码+5的大概性就会发生终极输入序号年夜于总页码,那末就要将其把持在页码数以内
pagestr="共"+allpage+"页";
pagestr+=page>1?"<ahref=""+HttpContext.Current.Request.CurrentExecutionFilePath+"?page=1">首页</a>;<ahref=""+HttpContext.Current.Request.CurrentExecutionFilePath+"?page="+pre+"">上一页</a>":"首页上一页";
//两头页处置,这个增添工夫庞大度,减小空间庞大度
for(inti=startcount;i<=endcount;i++)
{
pagestr+=page==i?"<fontcolor="#ff0000">"+i+"</font>":"<ahref=""+HttpContext.Current.Request.CurrentExecutionFilePath+"?page="+i+"">"+i+"</a>";
}
pagestr+=page!=allpage?"<ahref=""+HttpContext.Current.Request.CurrentExecutionFilePath+"?page="+next+"">下一页</a><ahref=""+HttpContext.Current.Request.CurrentExecutionFilePath+"?page="+allpage+"">末页</a>":"下一页末页";
returnpagestr;
}
publicstaticstringGetPageSql(stringFileName,DataListdatalistname,intpagesize)
{
intpage;
intallpage=0;
intnext=0;
intpre=0;
intstartcount=0;
intendcount=0;
stringpagestr="";
if(HttpContext.Current.Request.QueryString["page"]!=null)
page=Convert.ToInt32(HttpContext.Current.Request.QueryString["page"]);
else
page=1;
if(page<1){page=1;}
DataSetds=DataBindSql("EXECpagesql*,FROM"+FileName+","+pagesize+","+page,FileName);
datalistname.DataSource=ds;
datalistname.DataBind();
inttotal=DataBind(FileName);
//盘算总页数
if(pagesize!=0)
{
allpage=(total/pagesize);//盘算总页数
allpage=((total%pagesize)!=0?allpage+1:allpage);
allpage=(allpage==0?1:allpage);
}
next=page+1;
pre=page-1;
startcount=page/5*5;//两头页肇端序号
//两头页停止序号
endcount=startcount+5;
if(startcount<1){startcount=1;}//为了不输入的时分发生正数,设置假如小于1就从序号1入手下手
if(allpage<endcount){endcount=allpage;}//页码+5的大概性就会发生终极输入序号年夜于总页码,那末就要将其把持在页码数以内
pagestr="<a>"+page+"/"+allpage+"页</a>";
pagestr+=page>1?"<ahref=""+HttpContext.Current.Request.CurrentExecutionFilePath+"?page=1">首页</a><ahref=""+HttpContext.Current.Request.CurrentExecutionFilePath+"?page="+pre+"">上一页</a>":"首页上一页";
//两头页处置,这个增添工夫庞大度,减小空间庞大度
for(inti=startcount;i<=endcount;i++)
{
pagestr+=page==i?"<fontcolor="#ff0000">"+i+"</font>":"<ahref=""+HttpContext.Current.Request.CurrentExecutionFilePath+"?page="+i+"">"+i+"</a>";
}
pagestr+=page!=allpage?"<ahref=""+HttpContext.Current.Request.CurrentExecutionFilePath+"?page="+next+"">下一页</a><ahref=""+HttpContext.Current.Request.CurrentExecutionFilePath+"?page="+allpage+"">末页</a>":"下一页末页";
returnpagestr;
}
privatestaticintDataBind(stringFileName)
{
stringsql="select*from"+FileName;
DbConnectiondc=newDbConnection();
SqlConnectionmycon=newSqlConnection(dc.ConnectionString);
SqlDataAdaptermypter=newSqlDataAdapter(sql,mycon);
DataSetds=newDataSet();
mycon.Open();
mypter.Fill(ds,FileName);
mycon.Close();
inttotal=ds.Tables[0].Rows.Count;
returntotal;
}
privatestaticDataSetDataBindSql(stringsql,stringFileName)
{
DbConnectiondc=newDbConnection();
SqlConnectionmycon=newSqlConnection(dc.ConnectionString);
SqlDataAdaptermypter=newSqlDataAdapter(sql,mycon);
DataSetds=newDataSet();
mycon.Open();
mypter.Fill(ds,FileName);
mycon.Close();
returnds;
}
}
存储历程pagesql
复制代码代码以下:
CREATEPROCEDUREpagesql
@sqlSelectvarchar(800)--SELECT前面FROM后面的字段不必包括SELECT
,@sqlFromvarchar(800)--FROM前面的字段包括FROM
,@countPerPageint--每页数据行数
,@toPageint--要转到的页码
AS
BEGIN
--依据每页数据行数和要转到的页码失掉数据起止点
Declare@startint
Declare@endint
set@end=@countPerPage*@toPage
set@start=@countPerPage*(@toPage-1)+1
--一时表称号可随机定名
Declare@tmpTablevarchar(10)
SET@tmpTable=#tmp
Declare@sqlStrvarchar(800)
--创立数据源光临时表
SELECT@sqlStr=SELECTIdentity(int,1,1)ASRowIndex,
SELECT@sqlStr=@sqlStr+rtrim(@sqlSelect)+INTO+@tmpTable
SELECT@sqlStr=@sqlStr+rtrim(@sqlFrom)
--查询一时表失掉所必要的数据
SELECT@sqlStr=@sqlStr++SELECT+rtrim(@sqlSelect)+FROM+@tmpTable
SELECT@sqlStr=@sqlStr+WHERERowIndexBETWEEN+Convert(char,@start)+"AND"+Convert(char,@end)
--删除一时表
SELECT@sqlStr=@sqlStr++DROPTABLE+@tmpTable
EXEC(@sqlStr)
END
GO
呵呵,那你就关注微软的招聘信息以及别人的招聘经验啊,还有也不一定去做技术的,你如果真的想去就多了解了解。(其实我的意思是说想到微软做技术是很不容易的。 |
|