Search:
Namespaces
Discussions
.NET v1.1
Feedback
Ideas on how to convert this code from Classic ASP to ASP.NET?
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngmigrate' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Richard Clarke
I am getting into programming with the new ASP web controls etc. I
have a piece of code (used in a threaded discussion list) which is
classic ASP looks like this (Pseudo code):
do while not RS.EOF
response.write getIndent(rs.fields("IndentLevel") _
& rs.fields("Subject") etc etc
rs.movenext
loop
function getIndent(IndentLevel)
dim i, indentStr
i = 0
do while i < IndentLevel
indentStr = indentStr & "..."
i = i + 1
loop
getIndent = " "
end function
My question is how I can leverage the new web controls functionality
to make this code more efficient, neater etc. I am not sure what
control to use (
DataList
,
DataGrid
, Repeater). I want to ensure if at
all possible that the recordset comes out of the DB, has nothing done
to it, and is just bound to the control with the only processing being
the creation of the IndentLevel string.
Any ideas what would be the best way to do this? Or is my best bet
that I just use Classic ASP code and gain the benefits of it being
compiled anyway? As our forums get hit about 70,000 + times per day I
do want to get some performance boost from ASP.NET if I can. I am not
sure how I call a function inside a bound control. Also I have read
that the use of Eval in a bound contolr as it uses late binding
produces an overhead, so I don't want that if I can get away without
it. Typically there will be 200 - 500 rows which are output by this
DB call.
I would welcome any comments on this. Many thanks in advance.
Richard Clarke
Reply to this message...
Philip Q
Since you seem to be only moving one way through the code, I would use a
DataReader and do something like this -
While objRead.Read()
Response.Write(getIndent(objRead.GetInt32(0), objRead.GetString(1))
End While
Function getIndent(indentLevel as Integer, str as String) as String
Dim i = 0
Dim indentStr
While i < indentLevel
indentStr += "..."
i = i + 1
End While
Return indentStr + str
End Function
For more information on using the DataReader see
http://www.aspalliance.com/wisemonk/
view.aspx?id=AD101601" target="_blank">
http://www.aspalliance.com/wisemonk/
view.aspx?id=AD101601
--
----------------------------------
Philip Quinn -
Click here to reveal e-mail address
thisDevelopmentPage -
http://www.aspalliance.com/wisemonk/
"Richard Clarke" <
Click here to reveal e-mail address
> wrote in message
news:570675@aspngmigrate...
[Original message clipped]
Reply to this message...
Mitch Denny (VIP)
Richard,
Given the functionality you are after, you could
probably use the Repeater control then attach a
handler to the ItemDataBound event and use that
to manipulate each of your rows indentations.
The ItemDataBound event has
RepeaterItemEventArgs
which can be used to insert controls into the
ItemTemplate element. Before you do that, you'll
want to investigate the databinding capabilities
of the ASP.NET server controls.
Lets take it one step at a time, post a snippet
of the Classic ASP code you use to populate the
DataSet
(strip passwords) and we'll help you
rebuild that part of your application in .NET.
----------------------------------------
- Mitch Denny
-
Click here to reveal e-mail address
- +61 (414) 610-141
-
-----Original Message-----
From: Richard Clarke [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, 23 January 2002 02:09
To: aspngmigrate
Subject: [aspngmigrate] Ideas on how to convert this code from Classic
ASP to ASP.NET?
I am getting into programming with the new ASP web controls etc. I have
a piece of code (used in a threaded discussion list) which is classic
ASP looks like this (Pseudo code):
do while not RS.EOF
response.write getIndent(rs.fields("IndentLevel") _
& rs.fields("Subject") etc etc
rs.movenext
loop
function getIndent(IndentLevel)
dim i, indentStr
i = 0
do while i < IndentLevel
indentStr = indentStr & "..."
i = i + 1
loop
getIndent = " "
end function
My question is how I can leverage the new web controls functionality to
make this code more efficient, neater etc. I am not sure what control
to use (
DataList
,
DataGrid
, Repeater). I want to ensure if at all
possible that the recordset comes out of the DB, has nothing done to it,
and is just bound to the control with the only processing being the
creation of the IndentLevel string.
Any ideas what would be the best way to do this? Or is my best bet that
I just use Classic ASP code and gain the benefits of it being compiled
anyway? As our forums get hit about 70,000 + times per day I do want to
get some performance boost from ASP.NET if I can. I am not sure how I
call a function inside a bound control. Also I have read that the use
of Eval in a bound contolr as it uses late binding produces an overhead,
so I don't want that if I can get away without it. Typically there will
be 200 - 500 rows which are output by this DB call.
I would welcome any comments on this. Many thanks in advance.
Richard Clarke
| [aspngmigrate] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngmigrate.asp
= JOIN/QUIT
Reply to this message...
System.Data.DataSet
System.Web.UI.WebControls.DataGrid
System.Web.UI.WebControls.DataList
System.Web.UI.WebControls.RepeaterItemEventArgs
System.Windows.Forms.DataGrid
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com