views:

87

answers:

1

Hi,

i have to modify an asp.net application. The app consists of an huge gridview with lots of javascript, controls and cell modification (color cell etc.) in it.

Now i have to modify the gridview to add some more colums. Lot of code is based on identifying a cell based on its index e.g. row.Cells(1). Is there way to optimize this behaivor?

I dont like the thought to add a colum in the middel and then increment all indeces to match the new positions.

Ciao Richie

+1  A: 

You can create an Enum of your columns:

Enum GridColumnIndex
(
    Id = 0,
    Name = 1,
    ...
)

then use this Enum like this: row.Cells(GridColumnIndex.Id).
When you modify columns structure, you only have to update the Enum.

najmeddine
Thats an nice idea. Thank you!
Richard