ItemDataBound Event - How to access the previous record when this event is raised in DataGrid?

N

NH

ItemDataBound Event - How to access the previous record when this event is
raised in DataGrid?



During "ItemDataBound Event", I would like change the background color of a
column in previous row depending on some condition in the column in current
row.



Thanks in Advance,


NH
 
E

Eliyahu Goldin

ItemDataBound is not a good place for that. Use PreRender. Over there you
can loop through the rows freely, they are all before you.

Eliyahu
 
A

Andrew L. Van Slaars

In the ItemDataBound Event you could reference the prvious cell using the
itemindex property of the current item, such as:

private void dgReport_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)

{

e.Item.ItemIndex //current item index

e.Item.ItemIndex-1 //previous item index

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top