日期:2014-05-18  浏览次数:20467 次

请教一个关于GridView边框的问题
在ASP中的一个表格可以做成除了最下面的一行外其他的每一行都有一个border-bottom:#FF0000这样的边框(如下面的代码).那么在GridView中要怎么做才能行呢?小弟刚学ASP.NET不久,希望大家多多关照!!谢谢了!!
<table   style= "border-bottom:#ff0000   1px   solid; "> <tr>
<%
for   i=1   to   10
%>
<td   <%   if   i <> 10   then   response.write "style=border-bottom:#FF0000   1px   solid; "   %> > 0101001 </td>
<td   <%   if   i <> 10   then   response.write "style=border-bottom:#FF0000   1px   solid; "   %> > 0202002 </td>
<%
next
%>
</tr> </table>

------解决方案--------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int i;
//执行循环,保证每条数据都可以更新
for (i = 0; i < GridView1.Rows.Count; i++)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add( "onmouseover ", "c=this.style.backgroundColor;this.style.backgroundColor= '#00A9FF ' ");
//当鼠标移开时还原背景色
e.Row.Attributes.Add( "onmouseout ", "this.style.backgroundColor=c ");
}
}

------解决方案--------------------
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//加入鼠标滑过的高亮效果
if (e.Row.RowType == DataControlRowType.DataRow)//判定当前的行是否属于datarow类型的行
{
//当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色
e.Row.Attributes.Add( "onmouseover ", "currentcolor=this.style.backgroundColor;this.style.backgroundColor= 'yellow ',this.style.fontWeight= ' '; ");
//当鼠标离开的时候 将背景颜色还原的以前的颜色
e.Row.Attributes.Add( "onmouseout ", "this.style.backgroundColor=currentcolor,this.style.fontWeight= ' '; ");
}
}


我测试通过