Usuário com melhor resposta
Colorir Células da GridView

Pergunta
-
Olá pessoal,
Preciso colorir minhas células da GridView caso for um determinado texto mas não está a colorir:
protected void gdvDMGI_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridViewRow gvr = e.Row;
if (gvr.Cells[5].Text == "Executada")
{
gvr.Cells[5].BackColor = System.Drawing.Color.Green;
gvr.Cells[5].HorizontalAlign = HorizontalAlign.Center;
gvr.Cells[5].Font.Bold = true;
}
}
Respostas
-
Olá,
protected void gdvDMGI_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string Status = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "SEU_CAMPO")); if (Status == "Executada") { e.Row.Attributes["style"] = "background-color: green"; } } }
Se ajudou, vote como útil! Obrigado.
- Marcado como Resposta Cambrige quarta-feira, 20 de março de 2019 12:55
Todas as Respostas
-
Segue
protected void gdvDMGI_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataRowView dtRows = (DataRowView)e.Row.DataItem;if (Convert.ToString(dtRows.Row["SUA_COLUNA_DO_BANCO"]) == "Executada")
{
e.Row..Cells[5].BackColor = System.Drawing.Color.Green;
e.Row.Cells[5].HorizontalAlign = HorizontalAlign.Center;
e.Row.Cells[5].Font.Bold = true;
}
}
Espero que ajude!
Abraço, valeu =)
-
-
Olá,
protected void gdvDMGI_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string Status = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "SEU_CAMPO")); if (Status == "Executada") { e.Row.Attributes["style"] = "background-color: green"; } } }
Se ajudou, vote como útil! Obrigado.
- Marcado como Resposta Cambrige quarta-feira, 20 de março de 2019 12:55
-
-