This is an article about filling colors in gridview based on some conditions and values.
Say for an example: if a gridview has different departments in different locations. Need to color the gridview values based on the locations and display the top scorers of the winner’s department wise. As given below :
Add OnRowDataBound EVENT for the gridview and the find
protected void GvLeaderBorad_OnRowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
Label lblNett = e.Row.FindControl(“lbl_Net”) as Label;
if (lblNett.Text == Locations.Chennai.ToString())
e.Row.Cells.BackColor = System.Drawing.Color.DarkGreen;
When the color code is fetched from label placed inside the row . It will be applied to the entire row.
Thus in code itself when we bind the grid. Provide row color in the label and fetch the color code from it.
Apply the color code(Html hex code ex: #fffff ) to the gridview row.
Read SharePoint 2013 tutorials:
Hope this article will teach you how to add colors in gridview rows.
Check out Best Alternative to InfoPath -> Try Now
You May Also like the Following SharePoint Online Tutorials:
-: FREE PDF e-Book Download :-
51 JSOM Examples in SharePoint Online