c# datafield change cell background color
C#
<%@ Page Language="C#" AutoEventWireup="true"%>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Sql" %>
<%@ Import Namespace="System.Drawing" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
//Doing the binding when the page is loading for the first time (not on postbacks)
if (!IsPostBack)
{
//Test datasource (Creating a datatable with 10 columns. Then adding 3 rows. cell indeces are 0 based.)
DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("col1");
DataColumn dc2 = new DataColumn("col2");
DataColumn dc3 = new DataColumn("col3");
DataColumn dc4 = new DataColumn("col4");
DataColumn dc5 = new DataColumn("col5");
DataColumn dc6 = new DataColumn("col6");
DataColumn dc7 = new DataColumn("col7");
DataColumn dc8 = new DataColumn("col8");
DataColumn dc9 = new DataColumn("col9");
DataColumn dc10 = new DataColumn("col10");
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
dt.Columns.Add(dc5);
dt.Columns.Add(dc6);
dt.Columns.Add(dc7);
dt.Columns.Add(dc8);
dt.Columns.Add(dc9);
dt.Columns.Add(dc10);
//Second row index 9 has "Missing" as the text
dt.Rows.Add(new object[] { "cell1", "cell2", "cell3", "cell4", "cell5", "cell6", "cell7", "cell8", "cell9", "cell10" });
dt.Rows.Add(new object[] { "cell1", "cell2", "cell3", "cell4", "cell5", "cell6", "cell7", "cell8", "cell9", "Missing" });
dt.Rows.Add(new object[] { "cell1", "cell2", "cell3", "cell4", "cell5", "cell6", "cell7", "cell8", "cell9", "cell10" });
//Set datasource. Then bind it. (here the grid is using auto generated columns)
SYSGrid.DataSource = dt;
SYSGrid.DataBind();
}
}
protected void SYSGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[9].Text == "Missing")
{
e.Row.Cells[9].BackColor = Color.Red;
e.Row.Cells[9].ForeColor = Color.White;
}
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:gridview runat="server" ID="SYSGrid" OnRowDataBound="SYSGrid_RowDataBound"></asp:gridview>
</div>
</form>
</body>
</html>
Also in C#:
- Title
- unity making homing rocket
- Category
- C#
- Title
- gersener waves
- Category
- C#
- Title
- clear combobox c#
- Category
- C#
- Title
- scaffold-dbcontext sql server
- Category
- C#
- Title
- c sharp check if key in dictionary
- Category
- C#
- Title
- c# mathf.ceiling
- Category
- C#
- Title
- c# convert double to int
- Category
- C#
- Title
- asp.net c# set session timeout
- Category
- C#
- Title
- dontdestroyonload unity
- Category
- C#
- Title
- ignore fakeiteasy
- Category
- C#
- Title
- how to deactivate objects through scripts in unity
- Category
- C#
- Title
- dynamic convert type c#
- Category
- C#
- Title
- unity docs player input
- Category
- C#
- Title
- asp.net core 3.1: cast jObject to dictionary<string,string>
- Category
- C#
- Title
- C# .net core convert int to enum
- Category
- C#
- Title
- c# get desktop path
- Category
- C#
- Title
- c# if statement
- Category
- C#
- Title
- c# dictionaries
- Category
- C#
- Title
- array to list C
- Category
- C#
- Title
- c# read file stream
- Category
- C#
- Title
- gfortran: declare an array
- Category
- C#
- Title
- c# generate random number
- Category
- C#
- Title
- c# get list of all class fields
- Category
- C#
- Title
- unity 2d rotate towards direction
- Category
- C#
- Title
- unity load text resources from subfolder
- Category
- C#
- Title
- c# Authorization has been denied for this request
- Category
- C#
- Title
- in unity i want to destroy a gameobject when it hits the edge of the screen
- Category
- C#
- Title
- c# pull request
- Category
- C#
- Title
- json ignore property c#
- Category
- C#
- Title
- find gameobject with tag
- Category
- C#
- Title
- c# array Reverse method
- Category
- C#
- Title
- isInstanceOf nunit
- Category
- C#
- Title
- c# move with arrow keys
- Category
- C#
- Title
- asp net identity include phone number when registering
- Category
- C#
- Title
- freeze position unity c#
- Category
- C#
- Title
- what function is called just before the a script is ended c#
- Category
- C#
- Title
- unity how to load up a scene
- Category
- C#
- Title
- constructor in inherited class c#
- Category
- C#
- Title
- computer
- Category
- C#
- Title
- whats a string
- Category
- C#
- Title
- c# how to use inovke
- Category
- C#
- Title
- try catch c#
- Category
- C#
- Title
- unity check if gameobject is active
- Category
- C#
- Title
- c# get all inherited classes of a class
- Category
- C#
- Title
- how to get length of okobjectresult c#
- Category
- C#
- Title
- c# windows grab screenshot
- Category
- C#
- Title
- c# ^ operator
- Category
- C#
- Title
- C# datareadeer return null
- Category
- C#
- Title
- c sharp substring
- Category
- C#
- Title
- how to access first child of parent unity
- Category
- C#
- Title
- How to look at an object unity
- Category
- C#
- Title
- how to raycast unit
- Category
- C#
- Title
- unity delete specific text in a string
- Category
- C#
- Title
- how to locate a specific element in a list c#
- Category
- C#
- Title
- debug.log
- Category
- C#
- Title
- add object to list c#
- Category
- C#
- Title
- create new object from generic c#
- Category
- C#
- Title
- unity get data from firebase
- Category
- C#
- Title
- convert array object to int[] c#
- Category
- C#
- Title
- unity key detection
- Category
- C#
- Title
- unity check tag
- Category
- C#
- Title
- c# md5 hash file
- Category
- C#
- Title
- bytes size c#
- Category
- C#
- Title
- C# downloadstirng download old
- Category
- C#
- Title
- list clone - C#
- Category
- C#
- Title
- c# inotifypropertychanged best practices
- Category
- C#
- Title
- 2D follow ia unity 2D with agrorange
- Category
- C#
- Title
- .sh script: check if file exist
- Category
- C#
- Title
- grab reference from method parameter c#
- Category
- C#
- Title
- wpf use enum description
- Category
- C#
- Title
- vb.net tostring numeric format string
- Category
- C#
- Title
- unity array of child objects
- Category
- C#
- Title
- c# string to lowercase
- Category
- C#
- Title
- c# convert Unix time in seconds to datetime
- Category
- C#
- Title
- webutility.urlencode space
- Category
- C#
- Title
- c# replace foreach with lambda
- Category
- C#
- Title
- cshtml foreach
- Category
- C#
- Title
- c# float to string
- Category
- C#
- Title
- c# object clone
- Category
- C#
- Title
- open link c#
- Category
- C#
- Title
- c# reverse string
- Category
- C#
- Title
- unity making homing missile
- Category
- C#
- Title
- visual studio c# mark class deprecated
- Category
- C#
- Title
- unity remove gameobject
- Category
- C#
- Title
- defualtsize UWP c#
- Category
- C#
- Title
- No context type was found in the assembly
- Category
- C#
- Title
- how to select time and date in datetimepicker in c#
- Category
- C#
- Title
- trello
- Category
- C#
- Title
- flip boolean c#
- Category
- C#
- Title
- c# ienumerable to list
- Category
- C#
- Title
- c# filesystemwatcher double events
- Category
- C#
- Title
- c# math to radiant
- Category
- C#
- Title
- unity c# write line
- Category
- C#
- Title
- asp.net list all files in folder
- Category
- C#
- Title
- unity create primitive
- Category
- C#
- Title
- c# object to json string
- Category
- C#
- Title
- C# check many strings quickly
- Category
- C#
- Title
- c# check file exists
- Category
- C#
- Title
- 2d object look at object
- Category
- C#
- Title
- how to copy one array value to another without reference c#
- Category
- C#