Question

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

Was it helpful?

Solution

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

OTHER TIPS

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
              }
            }
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top