Is there a good tutorial on this or how would you do it with StringBuilder class
then just saying LiteralOutput.Text = StringBuilder class basically. I know how to do things in .net now but I know there are many ways to do something abut some are faster and better than the other ones. -----Original Message----- From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Dean Fiala Sent: Friday, June 24, 2005 4:42 PM To: [email protected] Subject: Re: [AspNetAnyQuestionIsOk] Speed of output................ building literals.......... There are many better ways to do this than updating the Text property of a Literal control in a loop: 1) use a datagrid and bind it your datasource 2) use XML from the datasource and format with XSLT 3) pushing the strings directly to the page's streamwriter (Response.Output) 4) build the string you want to output using the StringBuilder class and then set the LiteralOutput.Text property with its .ToString() method Everytime you update a string .NET you are actually creating a new string object. You are concatenating the LiteralOutput.Text property repeatedly, in a loop. That's going to be 1000s of objects created that are thrown away almost instantly. Going with options 3 or 4 will at least get you away from this situation. Options 1 or 2 will leverage a lot of the benefits of .NET, pull your formatting out of your code, and make it easier to read and maintain. On 6/24/05, Mike Belcher <[EMAIL PROTECTED]> wrote: > I wanted to ask some of the gurus here about speed and building output with > literals. I can and already have this it is a matter of speed. It seems a > lot slower than aspclassic was but is basically doing the same thing. So far > there are about 750 records that it outputs. This takes a minute with the > code below. I have a aspclassic site in comparison that outputs 3000 records > and does it in 1/10th the time. Is there a way to speed this up? Thanks. > > > <CODE> > ---------------------------------------------------------------------------- > ---- > > > While objDataReader.Read() > > 'DATABASE FIELDS > strTotalSubscribers = strTotalSubscribers + 1 > strUsername = objDataReader("Username") > strMembershipType = objDataReader("MembershipType") > strSitenameDB = objDataReader("Sitename") > strDateJoined = objDataReader("DateJoined") > strP_Updated = objDataReader("P_Updated") > strLastPaymentAmount = objDataReader("LastPaymentAmount") > strLastPaymentDate = objDataReader("LastPaymentDate") > strNextPaymentDueDate = objDataReader("NextPaymentDueDate") > > > > 'MembershipType Detection > If strMembershipType = "Premium Member" Then > strMembershipType = "<span style='background-color: > #00FF00'>" & strMembershipType & "</span>" > > ElseIf strMembershipType = "Standard Member" Then > > Else 'They aren't logged in or aren't a member. > > End If > > > 'Is Payment OverDue Detection > If strNextPaymentDueDate < DateTime.Now().ToShortDateString() > Then > strNextPaymentDueDate = "<span style='background-color: > #FF0000'>" & strNextPaymentDueDate & "</span>" > > Else 'They aren't logged in or aren't a member. > > End If > > > > LiteralOutput.Text = LiteralOutput.Text & "<tr>" > LiteralOutput.Text = LiteralOutput.Text & "<td align='center' > nowrap>" > > LiteralOutput.Text = LiteralOutput.Text & "<font face='Verdana' > size='1'>" > LiteralOutput.Text = LiteralOutput.Text & "<a target='_blank' > href='AdministratorUpdateSubscriber.aspx?username=" & strUsername & > "'>Edit</a></font><b><font face='Verdana' size='1' > color='#000080'>|</font></b>" > LiteralOutput.Text = LiteralOutput.Text & "<font face='Verdana' > size='1'><a target='_blank' > href='AdministratorDeleteSubscriber.aspx?username=" & strUsername & > "'>Delete</a></font>" > LiteralOutput.Text = LiteralOutput.Text & "<b><font > face='Verdana' size='1' color='#000080'>|</font></b>" > LiteralOutput.Text = LiteralOutput.Text & "<font face='Verdana' > size='1'><a target='_blank' href='s_profile.aspx?username=" & strUsername & > "'>View</a></font>" > > > LiteralOutput.Text = LiteralOutput.Text & "</td>" > LiteralOutput.Text = LiteralOutput.Text & "<td align='center' > nowrap><font face='Verdana' size='1'><b><a href='s_profile.aspx?username=" & > strUsername & "'>" & strUsername & "</a></b></font></td>" > LiteralOutput.Text = LiteralOutput.Text & "<td width='158' > align='center' nowrap><font face='Verdana' size='1'>" & strSitenameDB & > "</font></td>" > LiteralOutput.Text = LiteralOutput.Text & "<td width='128' > align='center' nowrap><font face='Verdana' size='1'>" & strMembershipType & > "</font></td>" > LiteralOutput.Text = LiteralOutput.Text & "<td width='70' > align='center' nowrap><font face='Verdana' size='1'>" & strLastPaymentAmount > & "</font></td>" > LiteralOutput.Text = LiteralOutput.Text & "<td width='86' > align='center' nowrap><font face='Verdana' size='1'>" & strLastPaymentDate & > "</font></td>" > LiteralOutput.Text = LiteralOutput.Text & "<td width='78' > align='center' nowrap><font face='Verdana' size='1'>" & > strNextPaymentDueDate & "</font></td>" > > LiteralOutput.Text = LiteralOutput.Text & "<td width='86' > align='center' nowrap><font face='Verdana' size='1'>" & strDateJoined & > "</font></td>" > LiteralOutput.Text = LiteralOutput.Text & "<td width='78' > align='center' nowrap><font face='Verdana' size='1'>" & strP_Updated & > "</font></td>" > > End While > > > <CODE> > ---------------------------------------------------------------------------- > ---- > > > > > > Yahoo! Groups Links > > > > > > > -- Dean Fiala Very Practical Software, Inc http://www.vpsw.com Yahoo! Groups Links Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
