CTOCIO IT专家网

天极传媒 比特网 | 天极网 | IT专家网 | IT商网 | 52PK游戏网 | 手机天极 | IT分众 |
IT专家网搜索

您现在的位置: IT专家网 > Web服务子站 > .NET技术

asp.net中显示DataGrid控件列序号的方法

作者: 佚名,  出处:中国IT实验室, 责任编辑: 包春林, 
2008-05-16 04:00
  在aps.net中多数据绑定的控件很多,论功能来说,应该属DataGrid最为齐全,但它没有提供现成的显示记录序号的功能,不过我们可以通过它所带的一些参数来间接得到序号......

  数据层代码如下:

  

      using System;

  using System.Data;

  using System.Data.SqlClient;

  using System.Configuration;

  namespace AspnetPaging

  {

  public class DataAccess

  {

  private static string connString = ConfigurationSettings.AppSettings["ConnString"];

  private DataAccess()

  {

  }

  public static DataSet GetCustomersData()

  {

  SqlConnection conn = new SqlConnection(connString);

  SqlCommand comm = new SqlCommand("GetCustomers",conn);

  comm.CommandType = CommandType.StoredProcedure;

  SqlDataAdapter dataAdapter = new SqlDataAdapter(comm);

  DataSet ds = new DataSet();

  dataAdapter.Fill(ds);

  return ds;

  }

  }

  }

  总结,上面的四种方法前两种其实处理起来是一样的,只是处理的时间不同而已;对于第三种我认为最简单,直接在前台页面绑定,不需要额外的辅助;对于第四种的方法绑定到前台我认为最为灵活,需要注意的是GetRecordIndex方法需要protected或public,使它的继承类能访问的到。

共4页。 9 1 2 3 4

网友评论

笔名 
请您注意:遵守国家有关法律、法规,尊重网上道德,承担一切因您的行为而直接或间接引起的法律责任。    IT专家网友拥有管理笔名和留言的一切权利。
  • 周排行榜
  • 月排行榜

邮件订阅

       
天极服务 | 关于我们 | 网站律师 | 加入我们 | 联系我们 | 广告业务 | 友情链接 | 我要挑错
All Rights Reserved, Copyright 2004-2008, Ctocio.com.cn
渝ICP证B2-20030003号 如有意见请与我们联系 powered by 天极内容管理平台CMS4i