GridView的其他用法小总结

GridView实现删除时弹出确认对话框:
View Code
1 if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
2 {
3 ((LinkButton)e.Row.Cells[6].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:\"" + e.Row.Cells[1].Text + "\"吗?')");
4 }

如图

DataView前自动生成编号

同样也是RowDataBound方法加上下面一段代码就ok了

View Code
1 if (e.Row.RowIndex != -1)
2 {
3 int id = e.Row.RowIndex + 1;
4 e.Row.Cells[0].Text = id.ToString();
5 }
posted @ 2011-07-06 18:44  笨笨的菜鸟  阅读(302)  评论(0编辑  收藏  举报