4 Answers, 1 is accepted

protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.WebControls.GridItemEventArgs e)
{
//Is it a GridDataItem
if
(e.Item
is
GridDataItem)
{
//Get the instance of the right type
GridDataItem dataBoundItem = e.Item
as
GridDataItem;
//if(dataBoundItem
.GetDataKeyValue
("ID").ToString() == "you Compared Text"
) // you can also use datakey also
if
( dataBoundItem[
"ColumnUniqueName"
].Text ==
"you Compared Text"
)
{
dataBoundItem[
"ColumnUniqueName"
].ForeColor = Color.Red;
// chanmge particuler cell
e.Item.BackColor = System.Drawing.Color.LightGoldenrodYellow;
// for whole row
//dataItem.CssClass = "MyMexicoRowClass";
}
}
}
Thanks
Jayesh Goyani

Hi Jayesh,
This is working good, but can i know how to make this change with out touching .cs page? can i get this change in aspx page?
I am getting these details from the database. can i change these things in a stored procedure?

Hello Many
if you bring it from the database and in aspx page, you can do so
protected
void
Page_Load(
object
sender, EventArgs e)
{
this
.full_grid.ItemDataBound +=
new
GridItemEventHandler(full_grid_ItemDataBound);
this
.full_grid.PreRender +=
new
EventHandler(full_grid_PreRender);
}

Hello Many
if you bring it from the database and in aspx page, you can do so
protected void Page_Load(object sender, EventArgs e)
{
this.full_grid.ItemDataBound += new GridItemEventHandler(full_grid_ItemDataBound);
this.full_grid.PreRender += new EventHandler(full_grid_PreRender);
}
code to fill grid
private void full_grid()
{
BL_Products bl = new BL_Products();/*business layer*/
this.grd_Product.DataSource = bl.getProductEstado(); /*Call procedure */
this.grd_Product.DataBind();
}
changing color
void full_grid_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
/*Get the instance of the right type*/
GridDataItem dataBoundItem = e.Item as GridDataItem;
/*Check the formatting condition */
if (dataBoundItem["state_p"].Text == "expired")
{
dataBoundItem["state_p""].ForeColor = System.Drawing.Color.Orange;
dataBoundItem["state_p""].Font.Bold = true;
/*e.Item.BackColor = System.Drawing.Color.LightGoldenrodYellow; */
}
}
}
void full_grid_PreRender(object sender, EventArgs e)
{
this.full_grid.MasterTableView.Rebind();
}