Click here to Skip to main content
15,894,720 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
C#
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.DataItem != null)
        {

            DataRowView drv = (DataRowView)e.Row.DataItem;
            string catName = Convert.ToString(drv["CategoryName"]);
            if (catName.Trim() == "Confections")
                e.Row.BackColor = System.Drawing.Color.LightBlue;
        }

    }

I Got Error in -

DataRowView drv = (DataRowView)e.Row.DataItem;

Advance thanks for valuable replay.
Posted
Updated 25-Nov-11 7:12am
v2
Comments
Karthik. A 25-Nov-11 13:16pm    
Okay, but what's the error?

1 solution

You may try by using GridView.RowDataBound Event.

GridView.RowDataBound Event
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900