I am working on an attendance portal
Screenshot of Portal
I want to change the cell color based on the text in cell, like if a cell contain "P" then its background color must be green and for "A" it must be Red.
How to achieve this?
I am working on an attendance portal
Screenshot of Portal
I want to change the cell color based on the text in cell, like if a cell contain "P" then its background color must be green and for "A" it must be Red.
How to achieve this?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Anupam MaitiRank #295 · 8.5K reputationPosted Jul 22, 2021, 9:38 AM EDT
protected void RowDataBound(Object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { if(e.Row.Cells[0].Text.Contains("P")) e.Row.Cells[0].BackColor = Color.Green; if(e.Row.Cells[0].Text.Contains("A")) e.Row.Cells[0].BackColor = Color.Red; } }You can try like above. Hope this will work for you.
Rahul Sharma195 reputationPosted Jul 25, 2021, 4:10 AM EDT