GridView鼠标经过改变行颜色!

来源:百度知道 编辑:UC知道 时间:2024/06/15 21:21:12
数据少的时候还可以,可上千条数据时就太慢了,还有一种前台调用JS的,感觉还是太慢,有没有高手指教下,如何让显示页面时候快点?
代码如下:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
e.Row.Cells[i].Attributes.Add("style", "border:1px solid gray");
}
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#d7e7fa';this.style.color='buttontext';this.style.cursor='hand';");
if (e.Row.RowIndex % 2 == 0)
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#DEDFDE'");
else
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
}
}
.

Repeater控件也跟其他空间差不多的 我记得不光有项模板 还有分割项模板吧 那你就把项模板里的东西复制粘贴到分各项模板里 然后给他重写一个样式不就行了么. 还省得你用这个循环遍历的方法了.性能能好一些

用js怎么可能太慢,用后台才会慢吧?要显示快就别用GridView,用Repeater控件

循环单元格干吗?

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#d5f4fe'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}