protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)//给每个列表加属性 背景色
{
//onmouseover
e.Row.Attributes.Add("onmouseover", "this.className='TC_Table_TDOver'");//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseout", "this.className='TC_Table_TD'");//当鼠标移开时还原背景色
{
if(GridView.HeaderRow.Cells.Count>2)
{
GridView.HeaderRow.Cells[3].Text = literalTitle.Text;//第几列自己定,
}
{
//当鼠标移动到行的时候改变颜色
if (e.Row.RowType == DataControlRowType.DataRow){
//onmouseover
e.Row.Attributes.Add("onmouseover", "this.className='TC_Table_TDOver'");//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseout", "this.className='TC_Table_TD'");//当鼠标移开时还原背景色
}
//改变列标题的值
if(GridView.HeaderRow!=null){
if(GridView.HeaderRow.Cells.Count>2)
{
GridView.HeaderRow.Cells[3].Text = literalTitle.Text;//第几列自己定,
}
}
//其实很多事情都可以在这里做,这个函数是Gridview进行每行数据绑定的时候,所有相关联事都可以在这里做,自己想想,不一一列举.
}