All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.Net+XML打造留言薄实例_[Asp.Net教程]
asp.net2.0中GridView控件应用实例
预载入和javascript,Image()对象_JavaScript技术_编程技术
AJAX在VS2005中的简单应用_[Asp.Net教程]
httpRuntime,一点经验_[Asp.Net教程]
Delphi过程和函数的重载
ASP.NET,2.0打造购物车和支付系统之二_[Asp.Net教程]
细节决定成败,ASP.NET中的蝴蝶效应_[Asp.Net教程]
XML HttpRequst对象基础方法学习_[XML教程]
PHP+MySQL扎实基本功_php资料_编程技术
Reading number is top 10 pictures
The girl of like self-time
移民小国也实惠2
More attractive than sora aoi1
In 2013 hercules Arnold classic2
The little woman's bright wire1
南昌铁路局攸县车站125户铁路职工微利房终成骗局
Players in the eyes of a perfect love2
Beautiful vacuum girl2
鸡蛋的新玩法
Forced sex girl living abroad2
Download software ranking
Ashlynn Video4
电脑知识及技巧大合集
Take off clothes to survival
Detective task-the top secret prostitution files
都市狐狸姑娘传
Jinling thirteen stock
Unix video tutorial6
塘西风月痕
功夫熊猫2(下集)
linux安装大全
delv published in(发表于) 2014/1/23 3:11:09 Edit(编辑)
Asp.Net实例:为DataGrid添加自动编号功能_[Asp.Net教程]

Asp.Net实例:为DataGrid添加自动编号功能_[Asp.Net教程]

Asp.Net实例:为DataGrid添加自动编号功能_[Asp.Net教程]

下面的代码实现在DataGrid中添加自动编号的功能,主要是在数据绑定时利用Item属性。


查看例子


DataGridWithLine.aspx


<%@ Page Language="vb" AutoEventWireup="false" Codebehind="DataGridWithLine.aspx.vb"
Inherits="aspxWeb.DataGridWithLine"%>



DataGridWithLine


















DataGridWithLine.aspx.vb


Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class DataGridWithLine
Inherits System.Web.UI.Page
Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid


#Region " Web 窗体设计器生成的代码 "


'该调用是 Web 窗体设计器所必需的。
Private Sub InitializeComponent()


End Sub


Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub


#End Region


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataGrid1.Columns(0).HeaderText = "序号"
DataGrid1.Columns(1).HeaderText = "文章标题"
DataGrid1.Columns(2).HeaderText = "创建日期"
Dim cnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("Test.mdb")
Dim strSQL As String = "SELECT TOP 21 Title,CreateDate FROM Document ORDER By CreateDate DESC"
Dim cn As New OleDbConnection(cnString)
cn.Open()
Dim cmd As New OleDbCommand(strSQL, cn)
Dim db As OleDbDataReader
db = cmd.ExecuteReader(CommandBehavior.CloseConnection)
DataGrid1.DataSource = db
DataGrid1.DataBind()
cn.Close()
cn = Nothing
cmd = Nothing
db.Close()
db = Nothing
End Sub


Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
If e.Item.ItemIndex <> -1 Then
e.Item.Cells(0).Text = e.Item.ItemIndex + 1
End If
End Sub
End Class



出自:【孟宪会之精彩世界】







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.