如果“是否有效”這一列的数据为无效的话,将这一行设置为灰色,效果如下
protected void gvCertificateCN_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
#region Check Box 全选
DataSet dt = (DataSet)gvCertificateCN.DataSource;
int tempStatus = 0;
int.TryParse(dt.Tables[0].Rows[e.Row.RowIndex]["RecId"].ToString(), out tempStatus);
//遍历所有行设置边框样式
foreach (TableCell tc in e.Row.Cells)
{
if (dt.Tables[0].Rows[e.Row.RowIndex]["isValid"].ToString() == "無效")
{
tc.Attributes["style"] = "background-color:LightGray";
}
}
ImageButton btnDelete = (ImageButton)e.Row.FindControl("btnDelete");
CWebUtil.setImageButtonEnabled(btnDelete, true);
btnDelete.Attributes.Add("onclick", "return confirm(\"你确定要删除此条记录吗?\");");
#endregion
}
}