?
Solved

ASP.Net - Response.Flush question

Posted on 2011-10-15
2
Medium Priority
?
347 Views
Last Modified: 2012-05-12
Hi all,

I have a question in regard to some older legacy code being run in a ASP.Net application.  Long story but I can't rewrite this into a datagrid etc. I have to keep it as is for now but I need to know how I may be able to change this a little.   I have a ASPX page with a table in the html and then within the table a label.  There is then code that loops through thousands of records and does a Response.Flush for every record to write to the label.  For large sets it completely hangs the browser and SQL Server.   Attached I am showing the snippet of code.  So you can see rows are written to the label within the table for each record.  I need to keep it for now somewhat the same but anything I can do with this like the flush etc?  

This will be rewritten later with new datagrids etc.  
Do While dr.Read
                strRow = "<tr id=trrow" & rownum & " name=trrow" & rownum _
                & ">" _
                & "<td align=left><input readonly style=" & _
                Chr(34) & "FONT-SIZE: xx-small" & Chr(34) & _
                " value=" & dr("AV_ID") & " style=" & Chr(34) & _
                "WIDTH: 0px" & Chr(34) & " type=text name=box" _
                & rownum & " id=box" & rownum & " onFocus=" & _
                Chr(34) & "nextfield ='box" & (rownum + 1) & "';" & _
                " prevfield ='box" & (rownum - 1) & "'; rownumb = " & rownum & ";  rownumber ='trrow" _
                & (rownum + 1) & "';" & " clearnumber ='trrow" _
                & (rownum) & "';" & " pclearnumber ='trrow" _
                & (rownum - 1) & "';" & " prownumber ='trrow" _
                & (rownum) & "';" & " ifield ='box" _
                & (rownum) & "';" & Chr(34) & "maxrec = 'trrow" _
                & (rownum + 1) & "';" & Chr(34) & "></td>" _
                & "<td align=left><b>" & dr("Part_No") & "</b></td>" _
                & "<td align=left><b>" & dr("MF") & "</b></td>" _
                & "<td align=left><b>" & dr("DC") & "</b></td>" _
                & "<td align=left><b>" & dr("Qty") & "</b></td>" _
                      & "<td align=left><b>" & dr("Price") & "</b></td>" _
                & "<td align=left><b>" & dr("Daterequested") & "</b></td>" _
                & "<td align=left><b>" & dr("Sold") & "</b></td>" _
                & "<td align=left><b>" & dr("Co_ID") & "</b></td>" _
                & "<td align=left><b>" & dr("internal") & "</b></td>" _
                & "</a></font></TR>"
                lblRec.Text &= strRow
                Response.Flush()
                rownum = rownum + 1
            Loop
            dr.Close()

Open in new window

0
Comment
Question by:sbornstein2
2 Comments
 
LVL 15

Accepted Solution

by:
Eyal earned 1000 total points
ID: 36975052
several things I can think of to improve performance
1) change to string builder (server side improvement) but the response.flash should be removed or pass it after the loop
2) only give the first 100 rows and provide paging
3) use css for styling
4) minimize the javascript by calling a function with the rownum
0
 

Author Closing Comment

by:sbornstein2
ID: 36975076
perfecto.  Yup did just that stringbuilder and applied after the loop and deleted the flush.  Thanks for the help awesome
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

840 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