GridView 下增加自动编号列
2008-07-22 09:15
519 查看
此处是用GridView自带分页
<asp:TemplateField HeaderText="序号">
<ItemTemplate>
<%# this.GridView1.PageIndex * this.GridView1.PageSize + Container.DataItemIndex + 1%>
</ItemTemplate>
</asp:TemplateField>
下面是用AspNetPager分页控件的情况:
<asp:TemplateField HeaderText="序号">
<ItemTemplate>
<%# (this.Pager1.CurrentPageIndex - 1) * this.Pager1.PageSize + Container.DataItemIndex + 1%>
</ItemTemplate>
</asp:TemplateField>
其它情况举一反三了!
GridView 增加删除确认以及鼠标划过行变色
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//如果是绑定数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
//当有编辑列时,避免出错,要加的RowState判断
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:/"" + e.Row.Cells[2].Text + "/"吗?')");
}
}
}
<asp:TemplateField HeaderText="序号">
<ItemTemplate>
<%# this.GridView1.PageIndex * this.GridView1.PageSize + Container.DataItemIndex + 1%>
</ItemTemplate>
</asp:TemplateField>
下面是用AspNetPager分页控件的情况:
<asp:TemplateField HeaderText="序号">
<ItemTemplate>
<%# (this.Pager1.CurrentPageIndex - 1) * this.Pager1.PageSize + Container.DataItemIndex + 1%>
</ItemTemplate>
</asp:TemplateField>
其它情况举一反三了!
GridView 增加删除确认以及鼠标划过行变色
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//如果是绑定数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
//当有编辑列时,避免出错,要加的RowState判断
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
((LinkButton)e.Row.Cells[4].Controls[0]).Attributes.Add("onclick", "javascript:return confirm('你确认要删除:/"" + e.Row.Cells[2].Text + "/"吗?')");
}
}
}
相关文章推荐
- ASP.NET - GridView 下增加自动编号列
- GridView 下增加自动编号列
- GridView 下增加自动编号列 及鼠标滑过行变色
- GridView增加自动编号列
- GridView下增加自动编号列
- GridView 增加自动编号列
- GridView 下增加自动编号列
- GridView控件自动编号实现
- 自动读取图片文件过程中文件名编号自动连接及编号增加问题
- GridView 自动编号字段 - TBSerialNumberField
- GridView自动编号
- GridView自动增加序号(三种实现方式)
- 给Repeater、Datalist和Datagrid增加自动编号列
- 如何对aspxgridview的行增加编号
- GridView自动增加序号
- DataList分页-增加自动编号列
- GridView,Repeater增加自动序号列
- MySQL自动增加的编号用法
- GridView实现自动编号;GridView实现自定义时间货币等字符串格式;GridView实现用“...”代替超长字符串;GridView一般换行与强制换行;GridView显示隐藏某一列;
- GridView自动增加序号(三种实现方式)