一聚教程网:一个值得你收藏的教程网站

热门教程

如何让DataGrid自动生成序号

时间:2022-06-30 10:45:31 编辑:袖梨 来源:一聚教程网

在DataGrid的第一列自动生成序号,如下图:
      代码实现:
前台(WebForm1.aspx):










<%#GetCount()%>








 
 
后台(WebForm1.aspx.cs):
int count;
private void Page_Load(object sender, System.EventArgs e)
{
     if(!IsPostBack)
     {
SqlConnection cnn = new SqlConnection();
cnn.ConnectionString = "data source=localhost;initial catalog=Northwind;password=;"
         +"persist security info=True;user id=sa;workstation id=APJ062;packet size=4096";

热门栏目