• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

Better way to interate through Checkboxes

Please Help
  I have the following code that iterates through thousands of textboxes in mvc 4 to see which ones are checked. The problem is that it takes to long. Is there  a faster way of finding out which boxes are check without iterating through all of them
checkbox.rtf
0
vcurtis
Asked:
vcurtis
1 Solution
 
plusone3055Commented:
have you thought about using a FOR EACH loop ?
0
 
vcurtisAuthor Commented:
Yes I thought about a 4 each but I am using BeginForms and it complained about it.
0
 
plusone3055Commented:
ah I see
well in that case your pretty much confired to the for loop with that array :(
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
vcurtisAuthor Commented:
Thank you but there that would take longer seeing that I have thousands of records
0
 
Snarf0001Commented:
"to see which ones are checked"

Are you sure you put the right code snippet up there?  The code provided isn't checking anything, it's just writing each checkbox onto the page... did I miss something?
0
 
vcurtisAuthor Commented:
Yes it is writing the code to the page but it takes so long for it to do it. I only have about 2500 records that contain 5 columns apiece.
 I would put the full code  but that would be asking to much of you guys. I was hoping there would be a faster way of the computer just processing the checked boxes and avoiding the rest

  This is the actual database call:


public void DeleteOrganization(IList<OrganizationVM> organizationList)
            {
                  foreach (var organization in organizationList.Where(o => o.IsSelected))
                  {
                        DeleteOrganization(organization.OrgId);
                  }
            }
0
 
Dustin HopkinsCommented:
The short answer is no, there is no better way to iterate the data.
But for display purposes, breaking the data into chunks could help.

Maybe providing a delete button with each record that performs the individual deletion asynchronously then removes the row using javascript, similar to how Amazon does it when you remove an item from your cart.


You're displaying 2500 records to the user at a time, maybe consider paging the data with a search option or something to break it into more acceptable chunks?

To get a better understanding:
Is it taking too long to load the page displaying the check boxes?
Or is it taking too long to iterate and delete on post back?
Or both?

Are you using an ORM, in-line SQL, or Stored Procs in the back end?

Also, are you opening and closing a database connection for each deletion?


Hope this helps,
Dustin
0
 
vcurtisAuthor Commented:
Thanks Dustin, I broke it into chunks and that made a huge difference.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now