itzArun
itzArun

Reputation: 691

How to Get Datagrid row index to get the previous row's cell value

I want to change the color of a row if the value of previous row's particular cell's value changes. I have a Datagrid which binds data from dataset. for eg.

S.NO. Quality Price Cent MM Size


1 AQ 78000 0.001 0.70


2 AQ 78000 0.001 0.75


3 AQ 76000 0.011 0.76


4 AQ 76000 0.012 0.77


I want to change the color of the next row if the value of Price changes. I couldnt get the rowindex in Datagrid. I tried with ItemBound event How can I change the row color comparing with its previous value.?

Upvotes: 0

Views: 745

Answers (1)

daniel
daniel

Reputation: 35703

you can access the Rows in the RowDataBound Event.

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
               // do stuff
        }
    }

Upvotes: 1

Related Questions