Click here to Skip to main content
15,916,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am having a gridview in that gridview there are 10,000 records are there. The user will select all the 10,000 and click on confirm button. I will update the confirmid for that each row as Y and save it in database. By using the foreach loop I am doing the process so its taking so much of time to update some times the browser gets freezed or else I am getting the Timed out error. How to avoid this situation is there any way to update the row without the foreach loop. Here is my code:

C#
private bool Confirm()
 {
     var result = from GridViewRow msgRow in grdPrice.Rows
                  where ((CheckBox)msgRow.FindControl("chkSelect")).Checked
                  select grdPrice.Rows[msgRow.RowIndex];
     obj = new ProductMasterInfo();
     DataTable dtPrice;
     string res = string.Empty;
     if (ViewState["UploadNo"] != null)
     {
         dtPrice = obj.GetEditData("P", ViewState["UploadNo"].ToString());
         foreach (GridViewRow row in result)
         {
             string refNo = (row.Cells[iTemp].FindControl("hfReferenceNo") as HiddenField).Value;
             DataRow[] dr = dtPrice.Select("ReferenceNo='" + refNo + "'");
             dr[0]["ConfirmId"] = "Y";
             dr[0]["UpdateId"] = SessionVarriables.UserIdSession;
             dr[0]["UpdateDate"] = DateTime.Now.ToString();
         }
          res = obj.UpdateDataByUploadNo(dtPrice, "P", ViewState["UploadNo"].ToString());
     }
     else
     {
         UserUtil.Message("No Data Uploaded", this.Page);
     }
     return isSaved(res);
 }


Thanks
Posted
Comments
Gopi Kishan Mariyala 31-Jan-14 7:20am    
So many rows updation into table will always take time. What is the connection timeout for your connection. And how are you updating data from datatable to database. Are you using forloop even there?
What is the code present in obj.UpdateDataByUploadNo
Member 7946563 31-Jan-14 7:27am    
No I am not using any for loop there I am just sending the datatable to update in the database with some select query

Simple: don't display so much information in one page.

Do you really think any user on this planet wants to go to a web site and then trawl through 10,000 rows of information looking for the data he is interested in?

If you page it, provide search and filter options to let him see a relevant subset of the data, then you processing time drops to near nothing (so your site responds in a timely manner) and your user is happier because he can find what he wants in the mass of raw data!
 
Share this answer
 
Comments
Member 7946563 31-Jan-14 7:28am    
No Our client is asking to provide the 10,000 records in a single page and they want to confirm it in a single click.
Matt T Heffron 31-Jan-14 13:50pm    
Then you might as well just confirm it for them, because I'd bet "dollars to donuts" they aren't actually looking at all 10,000 records every time before confirming! :-)
I'm guessing that they'll want to look at it when you first provide the app and when it passes a "sanity check", they'll just take it "on faith" and confirm without looking...
OriginalGriff 31-Jan-14 14:01pm    
Indeed. According to Amazon, (http://www.amazon.com/gp/search-inside/text-percentiles-help.html) the average novel is 64,000 words long. So if each row contains 6 words, the user will be reading the equivalent of a novel on each page.

Now, I'm a reasonably fast reader - I can read a paperback novel in two hours, but technical stuff takes much, much longer - and I just can't see the user sitting there for two hours a page...not without looking for a new job, anyway!
Rahul VB 31-Jan-14 12:15pm    
OG, OG, OG !!!!! hahahahaha :).

"Do you really think any user on this planet wants to go to a web site and then trawl through 10,000 rows of information looking for the data he is interested in?"

Well how have you been?
OriginalGriff 31-Jan-14 14:07pm    
Fine, fine. Yourself?
Not been up to much other than coding for a couple of days. Might get a film and some beers in for tomorrow - it's Wales versus Italy opening the 6 Nations Rugby tomorrow, then hopefully France beating England in the evening. (To paraphrase Andy Murray "I support Wales, and any team playing against England") :laugh:
Put this to your web.config;
C#
<system.web>
<customerrors mode="Off" />
<httpruntime apprequestqueuelimit="100" executiontimeout="60000" />
</system.web>
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900