Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Better way to interate through Checkboxes

Posted on 2014-04-17
8
Medium Priority
?
208 Views
Last Modified: 2014-04-18
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
Comment
Question by:vcurtis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 40007255
have you thought about using a FOR EACH loop ?
0
 

Author Comment

by:vcurtis
ID: 40007262
Yes I thought about a 4 each but I am using BeginForms and it complained about it.
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 40007269
ah I see
well in that case your pretty much confired to the for loop with that array :(
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:vcurtis
ID: 40007277
Thank you but there that would take longer seeing that I have thousands of records
0
 
LVL 23

Expert Comment

by:Snarf0001
ID: 40007909
"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
 

Author Comment

by:vcurtis
ID: 40007945
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
 
LVL 14

Accepted Solution

by:
Dustin Hopkins earned 2000 total points
ID: 40008438
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
 

Author Closing Comment

by:vcurtis
ID: 40009005
Thanks Dustin, I broke it into chunks and that made a huge difference.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question