惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
博客园 - Franky
罗磊的独立博客
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
V
V2EX
F
Fortinet All Blogs
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
U
Unit 42
GbyAI
GbyAI
A
About on SuperTechFans
WordPress大学
WordPress大学
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
Martin Fowler
Martin Fowler
D
DataBreaches.Net
The Cloudflare Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MongoDB | Blog
MongoDB | Blog

博客园 - 赵晓雷

让VS2008对JQuery语法的智能感知更完美一点 JavaScript实现走马灯效果[无缝连接、循环滚动] 向右 - 赵晓雷 - 博客园 JavaScript实现走马灯效果[无缝连接、循环滚动] 向左 - 赵晓雷 - 博客园 Windows忘记mysql密码的解决方案 JavaScript实现走马灯效果[无缝连接、循环滚动] 向下 - 赵晓雷 - 博客园 JavaScript实现走马灯效果[无缝连接、循环滚动] 向上 - 赵晓雷 - 博客园 jQuery实现在光标处插入文本 jquery 操作div - 赵晓雷 - 博客园 Jquery实现只能输入数字的文本框 - 赵晓雷 - 博客园 IIS6与Tomcat6的整合方法 asp.net控件开发基础(7) asp.net控件开发基础(6) asp.net控件开发基础(5) - 赵晓雷 - 博客园 asp.net控件开发基础(4) - 赵晓雷 - 博客园 asp.net控件开发基础(3) asp.net控件开发基础(2) asp.net控件开发基础(1) 详解ASP.NET配置文件Web.config [ASP.NET] Session 详解
Gridview自动编号 - 赵晓雷 - 博客园
赵晓雷 · 2009-07-23 · via 博客园 - 赵晓雷

为 Gridview 增加一个新的空白列,如下:
<asp:BoundField    HeaderText="序号">
              <ItemStyle HorizontalAlign="Center" Width="26px" />
              </asp:BoundField>

在 GridView RowDataBound 事件中编写代码,如下:
protected void RowDataBond1(object sender, GridViewRowEventArgs e)
{
           if (e.Row.RowIndex > -1)
          {
          
           e.Row.Cells[0].Text = Convert.ToString(e.Row.RowIndex + 1);//cells[0]表示改行的第一个单元格
          }
           
    }
这样就会在运行时自动创一个顺序编号的字段