用WIFI熊猫电视亚美娱乐怎么压才能嬴下载APP,才能看网络电视

asp.net gridview分页:第一页 下一页 1 2 3 4 上一页 最末页_asp.net开发_ThinkSAAS
asp.net gridview分页:第一页 下一页 1 2 3 4 上一页 最末页
asp.net gridview分页:第一页 下一页 1 2 3 4 上一页 最末页
内容来源: 网络
效果图:
功能简介:可使用上下键选中行,选中后点击修改,textbox获得gridview中的代码的数据。对你有帮助的话,请记得要点击“好文要顶”哦!!!不懂的,请留言。废话不多说了,贴码如下:
&head runat="server"&
&title&GridView分頁&/title&
&script type="text/javascript"&
var currentRowId = 0;
var styleName = "";
function SelectRow(ev, strGvName) {
var e = window.event ||
var keyCode = -1;
if (e.which == null)
keyCode = e.keyC // IE 
if (e.which & 0)
keyCode = e. // All others 
if (keyCode == 40)
MarkRow(currentRowId + 1, strGvName);
if (keyCode == 38) {
MarkRow(currentRowId - 1, strGvName);
document.getElementById("NUM").value = currentRowId;
function MarkRow(rowId, strGvName) {
var Grid = document.getElementById(strGvName);
var rowCount = Grid.rows.
if (document.getElementById(strGvName + rowId) == null)
if (rowId == rowCount) {
if (document.getElementById(strGvName + currentRowId) != null)
document.getElementById(strGvName + currentRowId).style.backgroundColor = styleN
currentRowId = rowId;
styleName = document.getElementById(strGvName + rowId).style.backgroundC
document.getElementById(strGvName + rowId).style.backgroundColor = &red&;
var obj = document.getElementById(strGvName);
obj.rows[rowId].cells[0].focus();
document.getElementById("NUM").value = currentRowId;
&/script&
&style type="text/css"&
.hidden
display:
&/style&
&/head&
核心代码:
using S
using System.Collections.G
using System.L
using System.W
using System.Web.UI;
using System.Web.UI.WebC
using System.Data.SqlC//請添加以下命名空間
using System.D
using System.D
public partial class _Default : System.Web.UI.Page
SqlConnection con = new SqlConnection("Server=SERVERDatabase=User ID=Pwd=");
private int _i = 0;//定義變量 ,查詢 Grid設定樣式有用到
protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)
getBind();
protected void getBind()
string str = "select * from im01";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(str, con);
da.Fill(ds);
DataTable dt = ds.Tables[0];
gvData.DataSource =
gvData.DataBind();
protected void gvData_PageIndexChanging(object sender, GridViewPageEventArgs e)
protected void gvData_RowCreated(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.Pager)
Label label_Index = new Label();
LinkButton Button_IndexFirst = new LinkButton();
LinkButton Button_IndexLast = new LinkButton();
LinkButton Button_IndexNext = new LinkButton();
LinkButton Button_IndexPrevious = new LinkButton();
Button_IndexFirst.Text = "第一頁 ";
mandName = "first";
Button_IndexFirst.ForeColor = Color.B
Button_IndexFirst.Click += new EventHandler(PageButtonClick);
Button_IndexNext.Text = " 下一頁 ";
mandName = "next";
Button_IndexNext.ForeColor = Color.B
Button_IndexNext.Click += new EventHandler(PageButtonClick);
Button_IndexPrevious.Text = "前一頁 ";
mandName = "previous";
Button_IndexPrevious.ForeColor = Color.B
Button_IndexPrevious.Click += new EventHandler(PageButtonClick);
Button_IndexLast.Text = "最末頁 ";
mandName = "last";
Button_IndexLast.ForeColor = Color.B
Button_IndexLast.Click += new EventHandler(PageButtonClick);
e.Row.Controls[0].Controls[0].Controls[0].Controls[0].Controls.AddAt(0, (Button_IndexFirst));
e.Row.Controls[0].Controls[0].Controls[0].Controls[0].Controls.AddAt(1, (Button_IndexPrevious));
int controlTmp = e.Row.Controls[0].Controls[0].Controls[0].Controls.Count - 1;
e.Row.Controls[0].Controls[0].Controls[0].Controls[controlTmp].Controls.Add(Button_IndexNext);
e.Row.Controls[0].Controls[0].Controls[0].Controls[controlTmp].Controls.Add(Button_IndexLast);
protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
//设置悬浮鼠标指针形状为"小手" 
e.Row.Attributes["style"] = "Cursor:hand";
string strGvName = "gvData";
e.Row.Attributes.Add("id", strGvName + _i.ToString());
e.Row.Attributes.Add("onKeyDown", "SelectRow(event,&" + strGvName + "&);");
e.Row.Attributes.Add("onClick", "MarkRow(" + _i.ToString() + ",&" + strGvName + "&);");
e.Row.Attributes.Add("tabindex", "0");
_i++;
protected void PageButtonClick(object sender, EventArgs e)
LinkButton clickedButton = ((LinkButton)sender);
if (mandName == "first")
gvData.PageIndex = 0;
else if (mandName == "next")
if (gvData.PageIndex & gvData.PageCount - 1)
gvData.PageIndex += 1;
else if (mandName == "previous")
if (gvData.PageIndex &= 1)
gvData.PageIndex -= 1;
else if (mandName == "last")
gvData.PageIndex = gvData.PageCount - 1;
getBind();
//修改
protected void btnUpd_Click(object sender, EventArgs e)
int intNum = 0;
if (this.NUM.Text == "" || this.NUM.Text == "0")
Response.Write("&script type="text/javascript"&alert(&請先查詢並選擇一筆資料!&)&/script&");
intNum = Convert.ToInt16(this.NUM.Text) - 1;
tbValue.Text = this.gvData.Rows[intNum].Cells[1].Text.ToString();
PHP开发框架
开发工具/编程工具
服务器环境
ThinkSAAS商业授权:
ThinkSAAS为用户提供有偿个性定制开发服务
ThinkSAAS将为商业授权用户提供二次开发指导和技术支持
让ThinkSAAS更好,把建议拿来。
开发客服微信asp.net gridview分页:第一页 下一页 1 2 3 4 上一页 最末页
投稿:mdxy-dxy
字体:[ ] 类型:转载 时间:
这篇文章主要介绍了asp.net gridview分页:第一页 下一页 1 2 3 4 上一页 最末页,可使用上下键选中行,选中后点击修改,textbox获得gridview中的代码的数据,需要的朋友可以参考下
功能简介:可使用上下键选中行,选中后点击修改,textbox获得gridview中的代码的数据。对你有帮助的话,请记得要点击“好文要顶”哦!!!不懂的,请留言。废话不多说了,贴码如下:
&head runat="server"&
&title&GridView分頁&/title&
&script type="text/javascript"&
var currentRowId = 0;
var styleName = "";
function SelectRow(ev, strGvName) {
var e = window.event ||
var keyCode = -1;
if (e.which == null)
keyCode = e.keyC // IE
if (e.which & 0)
keyCode = e. // All others
if (keyCode == 40)
MarkRow(currentRowId + 1, strGvName);
if (keyCode == 38) {
MarkRow(currentRowId - 1, strGvName);
document.getElementById("NUM").value = currentRowId;
function MarkRow(rowId, strGvName) {
var Grid = document.getElementById(strGvName);
var rowCount = Grid.rows.
if (document.getElementById(strGvName + rowId) == null)
if (rowId == rowCount) {
if (document.getElementById(strGvName + currentRowId) != null)
document.getElementById(strGvName + currentRowId).style.backgroundColor = styleN
currentRowId = rowId;
styleName = document.getElementById(strGvName + rowId).style.backgroundC
document.getElementById(strGvName + rowId).style.backgroundColor = 'red';
var obj = document.getElementById(strGvName);
obj.rows[rowId].cells[0].focus();
document.getElementById("NUM").value = currentRowId;
&style type="text/css"&
核心代码:
using System.Collections.G
using System.L
using System.W
using System.Web.UI;
using System.Web.UI.WebC
using System.Data.SqlC//請添加以下命名空間
using System.D
using System.D
public partial class _Default : System.Web.UI.Page
SqlConnection con = new SqlConnection("Server=SERVER\\Database=User ID=Pwd=");
private int _i = 0;//定義變量 ,查詢 Grid設定樣式有用到
protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)
getBind();
protected void getBind()
string str = "select * from im01";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(str, con);
da.Fill(ds);
DataTable dt = ds.Tables[0];
gvData.DataSource =
gvData.DataBind();
protected void gvData_PageIndexChanging(object sender, GridViewPageEventArgs e)
protected void gvData_RowCreated(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.Pager)
Label label_Index = new Label();
LinkButton Button_IndexFirst = new LinkButton();
LinkButton Button_IndexLast = new LinkButton();
LinkButton Button_IndexNext = new LinkButton();
LinkButton Button_IndexPrevious = new LinkButton();
Button_IndexFirst.Text = "第一頁 ";
mandName = "first";
Button_IndexFirst.ForeColor = Color.B
Button_IndexFirst.Click += new EventHandler(PageButtonClick);
Button_IndexNext.Text = " 下一頁 ";
mandName = "next";
Button_IndexNext.ForeColor = Color.B
Button_IndexNext.Click += new EventHandler(PageButtonClick);
Button_IndexPrevious.Text = "前一頁 ";
mandName = "previous";
Button_IndexPrevious.ForeColor = Color.B
Button_IndexPrevious.Click += new EventHandler(PageButtonClick);
Button_IndexLast.Text = "最末頁 ";
mandName = "last";
Button_IndexLast.ForeColor = Color.B
Button_IndexLast.Click += new EventHandler(PageButtonClick);
e.Row.Controls[0].Controls[0].Controls[0].Controls[0].Controls.AddAt(0, (Button_IndexFirst));
e.Row.Controls[0].Controls[0].Controls[0].Controls[0].Controls.AddAt(1, (Button_IndexPrevious));
int controlTmp = e.Row.Controls[0].Controls[0].Controls[0].Controls.Count - 1;
e.Row.Controls[0].Controls[0].Controls[0].Controls[controlTmp].Controls.Add(Button_IndexNext);
e.Row.Controls[0].Controls[0].Controls[0].Controls[controlTmp].Controls.Add(Button_IndexLast);
protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
//设置悬浮鼠标指针形状为"小手"
e.Row.Attributes["style"] = "Cursor:hand";
string strGvName = "gvData";
e.Row.Attributes.Add("id", strGvName + _i.ToString());
e.Row.Attributes.Add("onKeyDown", "SelectRow(event,'" + strGvName + "');");
e.Row.Attributes.Add("onClick", "MarkRow(" + _i.ToString() + ",'" + strGvName + "');");
e.Row.Attributes.Add("tabindex", "0");
protected void PageButtonClick(object sender, EventArgs e)
LinkButton clickedButton = ((LinkButton)sender);
if (mandName == "first")
gvData.PageIndex = 0;
else if (mandName == "next")
if (gvData.PageIndex & gvData.PageCount - 1)
gvData.PageIndex += 1;
else if (mandName == "previous")
if (gvData.PageIndex &= 1)
gvData.PageIndex -= 1;
else if (mandName == "last")
gvData.PageIndex = gvData.PageCount - 1;
getBind();
protected void btnUpd_Click(object sender, EventArgs e)
int intNum = 0;
if (this.NUM.Text == "" || this.NUM.Text == "0")
Response.Write("&script type=\"text/javascript\"&alert('請先查詢並選擇一筆資料!')&/script&");
intNum = Convert.ToInt16(this.NUM.Text) - 1;
tbValue.Text = this.gvData.Rows[intNum].Cells[1].Text.ToString();
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具全部设为已读 | 删除全部 首页 上页 下页 末页 1/22/2_521714吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0可签7级以上的吧50个
本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:22贴子:
全部设为已读 | 删除全部 首页 上页 下页 末页 1/22/2
全部设为已读 | 删除全部 首页 上页 下页 末页 1/22/2 下一封上一封
有1个来自湖南-的24岁MM在向你打招呼她看了你的资料,对你非常感兴趣哦~快去看看她吧
贴吧热议榜
使用签名档&&
保存至快速回贴当前位置:首页 > 关于我们 > 活动展示
2013闻道园感恩家人暨私人定制 · 平安夜
结缘琼布活佛---闻道园
二零一三年冬季政商领袖读书会116 好笑 &
140 好笑 &
2342 好笑 &
293 好笑 &
1086 好笑 &
1463 好笑 &
117 好笑 &
1401 好笑 &
334 好笑 &
436 好笑 &
374 好笑 &
240 好笑 &
1205 好笑 &
161 评论 &
200 好笑 &
153 好笑 &
糗事精选:0
婚姻:married
星座:巨蟹座
职业:搬砖汗
故乡:安徽 · 宿州
糗龄:1303天

我要回帖

更多关于 共享汽车 微辆才能 的文章

 

随机推荐