วันพุธที่ 23 เมษายน พ.ศ. 2551

[NET] สลับสี Row บน Datagrid

protected void dtgShowupload_RowCreated(object sender, GridViewRowEventArgs e)
{
      if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add(
"onmouseover", "this.style.backgroundColor='#CCCCCC';");
            
if (e.Row.RowIndex % 2 == 0)
                 {
                      e.Row.Attributes.Add(
"onmouseout", "style.backgroundColor='#EFF3FB'"); // หาสีที่ใกล้เคียงเองเนอะ....
                 
}
           
else 
                 
{
                      e.Row.Attributes.Add(
"onmouseout", "style.backgroundColor='White'");
                 }
        }

}

1 ความคิดเห็น: