Categories
askquestion

Other (better) way as the index to indentify a gridview row cells?

Other (better) way as the index to indentify a gridview row cells?

Ask Question

Asked
10 years, 6 months ago

Active
10 years, 6 months ago

Viewed
146 times

.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{
margin-bottom:0;
}

0

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

asp.net vb.net gridview

share|improve this question

asked Sep 15 ’09 at 14:27

RichardRichard

1,40522 gold badges1111 silver badges1515 bronze badges

add a comment
 | 

1 Answer
1

Active

Oldest

Votes

1

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.

share|improve this answer

answered Sep 15 ’09 at 14:38

manjimanji

43.9k44 gold badges8383 silver badges9696 bronze badges

Thats an nice idea. Thank you!

– Richard
Sep 15 ’09 at 14:51

add a comment
 | 

Your Answer

Thanks for contributing an answer to Stack Overflow!Please be sure to answer the question. Provide details and share your research!But avoid …Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.To learn more, see our tips on writing great answers.

Draft saved
Draft discarded

Sign up or log in

Sign up using Google

Sign up using Facebook

Sign up using Email and Password

Submit

Post as a guest

Name

Email
Required, but never shown

Post Your Answer

Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you’re looking for? Browse other questions tagged asp.net vb.net gridview or ask your own question.

The Overflow Blog

Tracking down performance pitfalls in Vue.js

Ways to Help the Fight Against COVID-19 from Home

Featured on Meta

Planned maintenance scheduled for Saturday, March 28, 2020 at 13:00 UTC (9AM…

An Update On Creative Commons Licensing

Community and Moderator guidelines for escalating issues via new response…

How does the Triage queue work?

Triage needs to be fixed urgently, and users need to be notified upon…

Related

6Getting row index from an ImageButton click in a GridView44How to get the cell value by column name not by index in GridView in asp.net2Gridview – colour cell row based on column data2Get Gridview Row Index1is there better ways to get gridview values?0Bold Gridview Rows Based on Cell Contents0highlight gridview cell by header and row values0Updating gridview row NOT finding data is gridview row0Cell on last row of GridView will not color in

Hot Network Questions

Is it possible to migrate old GLP2 project to GPL3?

Implementing any_of in C++

My professor is not teaching his online course himself, but uses publicly available videos instead. Is this appropriate?

Why John 1:1 in DRB is not literal translation from the Latin Vulgate?

Why should one pre-heat an oven?

Replace a sequential set of numbers with special character

Is there a Japanese word for “Easter holidays”?

Old short story about time travel: not physical, just as onlookers

Are Putin’s constitution amendments legal?

How can an omniscient being have limited awareness?

Unable to fill color in the intersection region of $y =sqrt{x}, y =x , using tikz by the given code

Do planets orbiting stars emit gravitational waves?

Is there a tool that will make a rounded cut in flat metal wire?

VertexContract and contraction of vertices of degree 2

How can I improve card design?

What is the correct way to convert 2 bytes to a signed 16-bit integer?

Could I still play cards from the activated ability of Golos while the Epic effect is active?

Why is sleep spelled with an aleph in Tehillim 127?

How can we define a non-spontaneous reaction?

Drawing 2.0A from 9v Battery for 5 Seconds

Aluminium shielding on a cobalt-60 source increases impulse rate

Ascending sequences of idempotents in inverse semigroups

Why don’t laws have examples?

Why does camouflage make some planes fly slower?

more hot questions

Question feed

Subscribe to RSS

Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-vb

Leave a Reply

Your email address will not be published. Required fields are marked *