亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

asp.net gridview分頁(yè):第一頁(yè) 下一頁(yè) 1 2 3 4 上一頁(yè) 最末頁(yè)

 更新時(shí)間:2014年12月11日 15:50:40   投稿:mdxy-dxy  
這篇文章主要介紹了asp.net gridview分頁(yè):第一頁(yè) 下一頁(yè) 1 2 3 4 上一頁(yè) 最末頁(yè),可使用上下鍵選中行,選中后點(diǎn)擊修改,textbox獲得gridview中的代碼的數(shù)據(jù),需要的朋友可以參考下

效果圖:

功能簡(jiǎn)介:可使用上下鍵選中行,選中后點(diǎn)擊修改,textbox獲得gridview中的代碼的數(shù)據(jù)。對(duì)你有幫助的話,請(qǐng)記得要點(diǎn)擊“好文要頂”哦!??!不懂的,請(qǐng)留言。廢話不多說(shuō)了,貼碼如下:

<head runat="server">
 <title>GridView分頁(yè)</title>
 <script type="text/javascript">
  var currentRowId = 0;
  var styleName = "";
  function SelectRow(ev, strGvName) {
   var e = window.event || ev;
   var keyCode = -1;
   if (e.which == null)
    keyCode = e.keyCode; // IE 
   else
    if (e.which > 0)
    keyCode = e.which; // 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.length;
   if (document.getElementById(strGvName + rowId) == null)
    return;
   if (rowId == rowCount) {
    return;
   }
   if (document.getElementById(strGvName + currentRowId) != null)
    document.getElementById(strGvName + currentRowId).style.backgroundColor = styleName;
   currentRowId = rowId;
   styleName = document.getElementById(strGvName + rowId).style.backgroundColor;
   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: none;
  }
 </style>
</head>

核心代碼:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;//請(qǐng)?zhí)砑右韵旅臻g
using System.Data;
using System.Drawing;

public partial class _Default : System.Web.UI.Page
{
 SqlConnection con = new SqlConnection("Server=SERVER\\xxx;Database=xxxx;User ID=xx;Pwd=xx;");
 private int _i = 0;//定義變量 ,查詢 Grid設(shè)定樣式有用到
 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 = dt;
  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 = "第一頁(yè) ";
   Button_IndexFirst.CommandName = "first";
   Button_IndexFirst.ForeColor = Color.Blue;
   Button_IndexFirst.Click += new EventHandler(PageButtonClick);

   Button_IndexNext.Text = " 下一頁(yè) ";
   Button_IndexNext.CommandName = "next";
   Button_IndexNext.ForeColor = Color.Blue;

   Button_IndexNext.Click += new EventHandler(PageButtonClick);

   Button_IndexPrevious.Text = "前一頁(yè) ";
   Button_IndexPrevious.CommandName = "previous";
   Button_IndexPrevious.ForeColor = Color.Blue;
   Button_IndexPrevious.Click += new EventHandler(PageButtonClick);

   Button_IndexLast.Text = "最末頁(yè) ";
   Button_IndexLast.CommandName = "last";
   Button_IndexLast.ForeColor = Color.Blue;
   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)
  {
   //設(shè)置懸浮鼠標(biāo)指針形狀為"小手" 
   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 (clickedButton.CommandName == "first")
  {
   gvData.PageIndex = 0;
  }
  else if (clickedButton.CommandName == "next")
  {
   if (gvData.PageIndex < gvData.PageCount - 1)
   {
    gvData.PageIndex += 1;
   }
  }
  else if (clickedButton.CommandName == "previous")
  {
   if (gvData.PageIndex >= 1)
   {
    gvData.PageIndex -= 1;
   }
  }
  else if (clickedButton.CommandName == "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('請(qǐng)先查詢並選擇一筆資料!')</script>");
   return;
  }
  else
  {
   intNum = Convert.ToInt16(this.NUM.Text) - 1;
   tbValue.Text = this.gvData.Rows[intNum].Cells[1].Text.ToString();
  }
 }
}

相關(guān)文章

  • asp.net中Timer無(wú)刷新定時(shí)器的實(shí)現(xiàn)方法

    asp.net中Timer無(wú)刷新定時(shí)器的實(shí)現(xiàn)方法

    這篇文章主要介紹了asp.net中Timer無(wú)刷新定時(shí)器的實(shí)現(xiàn)方法,是一個(gè)非常具有實(shí)用價(jià)值的技巧,需要用到Ajax技術(shù),需要的朋友可以參考下
    2014-08-08
  • Asp.net中通過(guò)Button打開另一個(gè)的frm

    Asp.net中通過(guò)Button打開另一個(gè)的frm

    本文通過(guò)實(shí)例代碼給大家介紹了asp.net中通過(guò)button打開另一個(gè)frm的方法,非常不錯(cuò),需要的朋友參考下吧
    2016-12-12
  • .NET日志框架Nlog使用介紹

    .NET日志框架Nlog使用介紹

    這篇文章介紹了.NET日志框架Nlog的使用方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2022-01-01
  • Visual Studio尋找C#程序必要的運(yùn)行庫(kù)文件

    Visual Studio尋找C#程序必要的運(yùn)行庫(kù)文件

    這篇文章主要為大家詳細(xì)介紹了Visual Studio尋找C#程序必要的運(yùn)行庫(kù)文件,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • 快速入門ASP.NET Core看這篇就夠了

    快速入門ASP.NET Core看這篇就夠了

    ASP.NET Core 是一個(gè)由微軟創(chuàng)建的,用于構(gòu)建 web 應(yīng)用、API、微服務(wù) 的 web 框架。通過(guò)本文的學(xué)習(xí)就能快速的入門ASP.NET Core,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • asp.net?core?MVC?全局過(guò)濾器之ExceptionFilter過(guò)濾器(1)

    asp.net?core?MVC?全局過(guò)濾器之ExceptionFilter過(guò)濾器(1)

    這篇文章主要為大家詳細(xì)介紹了asp.net?core?MVC?全局過(guò)濾器之ExceptionFilter過(guò)濾器,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • .net core異常中間件的使用

    .net core異常中間件的使用

    本文主要簡(jiǎn)單介紹一下異常中間件的使用,學(xué)習(xí).net core的同學(xué)可以了解下本文
    2021-06-06
  • asp.net“服務(wù)器應(yīng)用程序不可用” 解決方法

    asp.net“服務(wù)器應(yīng)用程序不可用” 解決方法

    服務(wù)器應(yīng)用程序不可用 您試圖在此 Web 服務(wù)器上訪問(wèn)的 Web 應(yīng)用程序當(dāng)前不可用。請(qǐng)點(diǎn)擊 Web 瀏覽器中的“刷新”按鈕重試您的請(qǐng)求。 管理員注意事項(xiàng): 詳述此特定請(qǐng)求失敗原因的錯(cuò)誤消息可在 Web 服務(wù)器的系統(tǒng)事件日志中找到。請(qǐng)檢查此日志項(xiàng)以查明導(dǎo)致該錯(cuò)誤發(fā)生的原因。
    2008-10-10
  • 淺談.NET中加密和解密的實(shí)現(xiàn)方法分享

    淺談.NET中加密和解密的實(shí)現(xiàn)方法分享

    這篇文章介紹了.NET中加密和解密的實(shí)現(xiàn)方法,有需要的朋友可以參考一下
    2013-11-11
  • ASP.NET Core WebApi中使用FluentValidation驗(yàn)證數(shù)據(jù)模型的方法

    ASP.NET Core WebApi中使用FluentValidation驗(yàn)證數(shù)據(jù)模型的方法

    這篇文章主要介紹了ASP.NET Core WebApi中使用FluentValidation驗(yàn)證數(shù)據(jù)模型的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-01-01

最新評(píng)論