|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
只要你想学,就没什么优缺点,上面那位大哥已经把网上的评论说了,但我认为想学哪个都一样,不然它就不可能在当今时代数字艺术方面存活到今天datagrid|存储历程|分页|数据
<%@ImportNamespace="System.Data.SqlClient"%>
<%@ImportNamespace="System.Data"%>
<ScriptRunat="Server">
DimconNorthwindAsSqlConnection
DimstrSelectAsString
DimintStartIndexAsInteger
DimintEndIndexAsInteger
SubPage_Load
DimcmdSelectAsSqlCommand
btnFirst.Text="首页"
btnPrev.Text="上一页"
btnNext.Text="下一页"
btnLast.Text="末页"
conNorthwind=NewSqlConnection("Server=192.168.4.1;UID=sa;PWD=XXXXXX;Database=NorthWind")
IfNotIsPostBackThen
GetTotalPages
strSelect="SELECTCOUNT(OrderID)FROMOrders"
cmdSelect=NewSqlCommand(strSelect,conNorthwind)
conNorthwind.Open()
dgrdProducts.VirtualItemCount=(cmdSelect.ExecuteScalar()/dgrdProducts.PageSize)
conNorthwind.Close()
BindDataGrid
EndIf
EndSub
SubBindDataGrid
DimdadProductsAsSqlDataAdapter
DimdstProductsAsDataSet
intEndIndex=dgrdProducts.PageSize
dadProducts=NewSqlDataAdapter("OrdersPaged",conNorthwind)
dadProducts.SelectCommand.CommandType=CommandType.StoredProcedure
dadProducts.SelectCommand.Parameters.Add("@PageIndex",intStartIndex)
dadProducts.SelectCommand.Parameters.Add("@PageSize",intEndIndex)
dstProducts=NewDataSet
dadProducts.Fill(dstProducts)
dgrdProducts.DataSource=dstProducts
dgrdProducts.DataBind()
EndSub
SubdgrdProducts_PageIndexChanged(sAsObject,eAsDataGridPageChangedEventArgs)
intStartIndex=e.NewPageIndex
dgrdProducts.CurrentPageIndex=e.NewPageIndex
BindDataGrid
EndSub
SubPagerButtonClick(ByValsenderAsObject,ByValeAsEventArgs)
DimargAsString=sender.CommandArgument
SelectCasearg
Case"next"
If(dgrdProducts.CurrentPageIndex<(dgrdProducts.PageCount-1))Then
dgrdProducts.CurrentPageIndex+=1
EndIf
Case"prev"
If(dgrdProducts.CurrentPageIndex>0)Then
dgrdProducts.CurrentPageIndex-=1
EndIf
Case"last"
dgrdProducts.CurrentPageIndex=(dgrdProducts.PageCount-1)
CaseElse
pagenumber
dgrdProducts.CurrentPageIndex=System.Convert.ToInt32(arg)
EndSelect
intStartIndex=dgrdProducts.CurrentPageIndex
BindDataGrid
EndSub
</Script>
<html>
<head><title>Paging.aspx</title></head>
<body>
<formRunat="Server">
<asp:DataGridRunat="Server"
ID="dgrdProducts"
showheader="false"
AllowPaging="True"
AllowCustomPaging="True"
PageSize="10"
OnPageIndexChanged="dgrdProducts_PageIndexChanged"
PagerStyle-Mode="NumericPages"
AlternatingItemStyle-BackColor="#eeaaee"
HeaderStyle-BackColor="#aaFFdd"
Font-Size="10pt"
Font-Name="Verdana"
CellSpacing="0"
CellPadding="3"
GridLines="Both"
BorderWidth="1"
BorderColor="black"
PagerStyle-HorizontalAlign="Right">
<AlternatingItemStyleBackColor="#EEEEEE"></AlternatingItemStyle>
</asp:datagrid>
<asp:linkbuttonid="btnFirst"runat="server"Font-Name="verdana"Font-size="8pt"ForeColor="navy"CommandArgument="0"></asp:linkbutton>
<asp:linkbuttonid="btnPrev"runat="server"Font-Name="verdana"Font-size="8pt"ForeColor="navy"CommandArgument="prev"></asp:linkbutton>
<asp:linkbuttonid="btnNext"runat="server"Font-Name="verdana"Font-size="8pt"ForeColor="navy"CommandArgument="next"></asp:linkbutton>
<asp:linkbuttonid="btnLast"runat="server"Font-Name="verdana"Font-size="8pt"ForeColor="navy"CommandArgument="last"></asp:linkbutton>
</form>
</html>
上面是存储历程:
CREATEPROCEDUREOrdersPaged
(
&nb
减少客户内IT专业人才缺乏带来的影响。ASP的客户员工利用浏览器进入相关的应用软件,简单易用,无需专业技术支持。 |
|