Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET1.0 .NET1.1 .NET2.0 C#2.0 , +
Hi
This is a general Q is looping through controles faster then directly accessing it in WEB if yes then how if no then how can some one plz Explain me this
Thanks in advance
Posted 4-Jul-11 22:42pm
Edited 4-Jul-11 22:43pm
v2
Comments
CPallini at 5-Jul-11 5:04am
   
Well 'direct' in 'direct access' is an hint, isn't it?
Steven.Pinto2000 at 5-Jul-11 5:11am
   
yes
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

No, looping to lists is never faster than accessing data directly. This is because it will always perform extra steps and checks.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Direct access is always faster than looping as JV99999 pointed out the reason.
 
But in certain circumstances where you got to add/show random controls based on some criteria, then accessing it thru loops is better way to set or retrieve its value or so. Not necessary for each stage you got to access it via loop only, you can add TAG to each control and access particular control based on its index.
 
Conclusion : For stable controls, direct access is preferred and for dynamically adding a # of specific controls (Like textboxes, checkboxes, etc) yuo may access it via loops but always loops are not required and nor the preferred way.
 
Now it depends on your requirements and what do you want to do.
 
Hope this helps !
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.141022.2 | Last Updated 5 Jul 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100