介绍
本篇文章给大家分享的是有关怎么在asp.net中利用显示数据表格实现一个分页跳转功能,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
ASP。网是什么
ASP。网是开源,跨平台,高性能,轻量级的网络应用构建框架,常用于通过HTML, CSS, JavaScript以及服务器脚本来构建网页和网站。
& lt; head runat=皊erver"比; ,& lt; title>显示数据表格分頁& lt;/title> ,& lt; script 类型=拔谋?javascript"比; var 才能;currentRowId =, 0; var 才能;styleName =,““ function 才能SelectRow (ev, strGvName), { ,,var e =, window.event | |,电动汽车; ,,var keyCode =, 1; ,,if (e.which ==, null) ,,,keyCode =, e.keyCode;,//, IE 其他的,, ,,,if (e.which 祝辞,0) ,,,keyCode =, e.which;,//, All others ,,if (keyCode ==, 40) ,,,MarkRow(时间+ currentRowId 1, strGvName); ,,if (keyCode ==, 38), { ,,,MarkRow (currentRowId 安康;1,strGvName); ,,} ,,. getelementbyid (“NUM") .value =, currentRowId; ,,} function 才能;MarkRow (rowId,, strGvName), { ,,var Grid =, . getelementbyid (strGvName); ,,var rowCount =, Grid.rows.length; ,,if (. getelementbyid(时间+ strGvName rowId),==, null) ,,,返回; ,,if (rowId ==, rowCount), { ,,,返回; ,,} ,,if (. getelementbyid(时间+ strGvName currentRowId), !=, null) ,,,. getelementbyid(时间+ strGvName currentRowId) .style.backgroundColor =, styleName属性; ,,currentRowId =, rowId; ,,styleName =, . getelementbyid(时间+ strGvName rowId) .style.backgroundColor; ,,. getelementbyid(时间+ strGvName rowId) .style.backgroundColor =, & # 39;红色# 39;; ,,var obj =, . getelementbyid (strGvName); ,,obj.rows [rowId] .cells [0] .focus (); ,,. getelementbyid (“NUM") .value =, currentRowId; ,,} ,& lt;/script> ,& lt; style 类型=拔谋?css"比; .hidden才能 {才能 ,,,显示:没有; ,,} ,& lt;/style> & lt;/head>
核心代码:
using 系统; using System.Collections.Generic; using 来; using 包含; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient;//請添加以下命名空間 using System.Data; using System.Drawing; public partial  class _Default : System.Web.UI.Page { ,SqlConnection con =, new SqlConnection(“服务器=服务器\ \ xxx;数据库=xxxx; User ID=xx; Pwd=xx;“); ,private int _i =, 0;//定義變量,,查詢,网格設定樣式有用的到 ,protected void  employee (object ,发送方,EventArgs e) ,{ if 才能;(Page.IsPostBack !) {才能 ,,getBind (); ,,} ,} ,protected void  getBind () ,{ string 才能;str =,“select *,得到im01"; DataSet 才能;ds =, new 数据集(); SqlDataAdapter 才能;da =, new SqlDataAdapter (str,,); da.Fill才能(ds); DataTable 才能;dt =, ds.Tables [0]; gvData.DataSource 才能=,dt; gvData.DataBind才能(); ,} ,protected void  gvData_PageIndexChanging (object ,发送方,GridViewPageEventArgs e) ,{ ,} ,protected void  gvData_RowCreated (object ,发送方,GridViewRowEventArgs e) ,{ if 才能;(e.Row.RowType ==, DataControlRowType.Pager) {才能 ,,Label label_Index =, new 标签(); ,,LinkButton Button_IndexFirst =, new LinkButton (); ,,LinkButton Button_IndexLast =, new LinkButton (); ,,LinkButton Button_IndexNext =, new LinkButton (); ,,LinkButton Button_IndexPrevious =, new LinkButton (); ,,Button_IndexFirst.Text =,“第一頁,“; ,,Button_IndexFirst.CommandName =,“至上”; ,,Button_IndexFirst.ForeColor =, Color.Blue; null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null null怎么在asp.net中利用显示数据表格实现一个分页跳转功能