Iatrochemist
Iatrochemist

Reputation: 276

Changing the style of specific records in GridView

I'm designing a logistics system in ASP.Net . In the Order processing page, orders are displayed by Grid View,i want to change the font style of the rows to BOLD, which are marked as"ordedr not processed". thanks.

order processing page

Upvotes: 2

Views: 1804

Answers (2)

user2609915
user2609915

Reputation:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        string OrStatus = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Orderstatus"));
        if (OrStatus == "Order not processed")
        {
            //You can use whatever you want to play with rows
            e.Row.Cells[0].Font.Bold = true;
            e.Row.Cells[2].CssClass = "gridcss";
        }
    }
}

Follow that code. It will helps

Upvotes: 3

Sain Pradeep
Sain Pradeep

Reputation: 3125

You can do this in "rowdatabound" event of grid.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            GridView grid = GridView1;
            GridViewRow row = e.Row;
            if (row.RowType == DataControlRowType.DataRow)
            {

               string orderstatus= Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Orderstatus"));
              if(orderstatus=="Order not processed)
              {
                   //write your code to change css
              }
            }
        }

Upvotes: 2

Related Questions