GridView last row

Capodecina
Permabanned
Joined
31 Dec 2003
Posts
5,172
Location
Barrow-In-Furness
ASP.net GridView last row

I'm trying to access the last row of my GridView but i'm not sure how to do it?

I have some totals in the last row of each column (NOT THE FOOTER) and I want to create an if statement that will change the colour .

The thing is, the totals are done in SQL, so there's no binding to any form of control (Label etc), so I don't know how to go about setting the colours, if that makes any sense?
 
Last edited:
need more info to help

which grid view are you using
what language are you using

if you are using the vb.net and a datagridview then you would do it something like this.

Code:
Dim adatagridviewcell As DataGridViewCell = aDataGridView.Item(somecolumn, aDataGridView.RowCount)

adatagridviewcell.Style.BackColor = Color.Crimson
 
Apologies, ASP.net and VB.

I understand i'll have to do some kind of count, but how do I format only the final row?
 
Code:
Dim adatagridviewcell As DataGridViewCell = aDataGridView.Item(somecolumn, aDataGridView.RowCount)

adatagridviewcell.Style.BackColor = Color.Crimson

DataGridViewCell isn't defined.

Still no luck with this. I know how to set the entire last row a colour, but I need to set the inidivdual cells based on an If statement.

Code:
LoggedHoursGridView.Rows(LoggedHoursGridView.Rows.Count - 1).BackColor = System.Drawing.Color.Red

That sets the final row background colour to red, but I can't workout how to do each cell.
 
int cellNumber = 4;

LoggedHoursGridView.Rows(LoggedHoursGridView.Rows.Count - 1).Cells[cellNumber].BackColor = System.Drawing.Color.Red

try that, i think thats how i'd do it in C# anyways
 
Back
Top Bottom