一、实现鼠标悬停高亮显示
在girdview中的RowDataBound事件中写下如下代码:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#6699ff';");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;");
}
}
二、判断GridView是否处于编辑状态
if ((e.Row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
三、获取GridView列索引
四、格式化GridView数据列字段
<asp:BoundField DataField="end_time" HeaderText="数量" DataFormatString="{0:F2}" HtmlEncode="false" />
<%# Container.DataItemIndex %>