[原创]给DataGrid快速添加自动编号
2006-03-30 09:03
281 查看
#region 声明
//----------------------------------------------------------------------
//
// 作者: lgq
//
// 给DataGrid添加快速添加自动编号
// lgq_1314@hotmail.com
//
//----------------------------------------------------------------------
#endregion
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem | e.Item.ItemType == ListItemType.Item)
{
e.Item.Cells[0].Text = "<font color=/"RoyalBlue/">"+Convert.ToString(e.Item.ItemIndex + 1)+"</font>";
}
}
方法二:
string sqlread="......";
System.Data.DataSet ds = Framework.ComLib.DataBase.Query(sqlread);
ds.Tables[0].Columns.Add("ID");
int i=0;
foreach(System.Data.DataRow dr in ds.Tables[0].Rows)
{
i++;
dr["ID"] = i.ToString();
}
DataGrid.DataSource = ds;
DataGrid.DataBind();
相关文章推荐
- [原创]给DataGrid快速添加自动编号
- 为DataGrid添加自动编号功能
- 为DataGrid添加自动编号功能
- 【原创】ListView快速滚动至新添加一行(自动滚动)
- 为DataGrid添加自动编号功能
- 给DataGrid添加index序号,自动编号
- DataGrid中添加自动编号
- 为DataGrid添加自动编号功能
- 如何在DataGrid中添加自动编号的功能
- 为DataGrid添加自动编号功能
- 如何在ASP.NET中为DataGrid添加自动编号的功能
- 在DataGrid中添加自动编号的功能
- 如何在DataGrid中添加自动编号的功能
- 为DataGrid添加自动编号功能
- 为DataGrid添加自动编号功能
- 原创!在ASP中怎样获取Identily的值(怎么获取新添加记录的自动编号)
- 为DataGrid添加自动编号功能
- 为DataGrid添加自动编号功能
- 为DataGrid添加自动编号功能
- 为DataGrid添加自动编号功能