0

I have Classic ASP application, within a class, I extract the record by a simple select. In the view page (index.asp) I want to show the record, so I instantiated a class like:

Set user_profile = New user

Now I want manipulate and show records as I want:

<li><%=user.name%></li>
<li><%=user.surname%></li>
.......

In this case, logically, I have not a loop but I see only 1 record for instance. Is it possible to add a for each in the view page like a real MVC system in ASP classic?

to clarify, i have this situation:

class category_view 
    Public id
    Public name
    Private Sub Class_Initialize()
            sql = " SELECT * FROM category_tbl ORDER BY category_name ASC "
            Set rs_cat = Server.CreateObject("ADODB.Recordset")
            rs_cat.Open sql, Conn ,1,3
            if rs_cat.RecordCount > 0 then
                rs_rows = rs_cat.GetRows()
                rs_catLoop = ubound(rs_rows,2)
                For iCounter = 0 to rs_catLoop
                    id = rs_rows(0,iCounter)
                    name = rs_rows(1,iCounter)
                Next
            End if
            rs_cat.close
    End Sub
    Private Sub Class_Terminate()
    End Sub
end class

View page:

Set category = New category_view
(for each here)
<%=category.name%>

I need to access and reuse recordset information everywhere

user692942
  • 16,398
  • 7
  • 76
  • 175
Jeager
  • 3
  • 2
  • Where is the data you want to loop through, (eg is it in an array or a database table?) – John Apr 18 '15 at 14:14
  • Does this question offer any clues? http://stackoverflow.com/questions/4558998/classic-asp-3-0-create-array-from-a-recordset – John Apr 19 '15 at 13:00
  • @John I havn't problem with getrow(), my first question was: I have 2 pages, class.asp and index.asp. In class.asp i have all code that include the select and getrow. In the index.asp i want to access and manipulate only single record and separate the logic from the view. There is a way? – Jeager Apr 19 '15 at 22:03
  • What I'd do would be to make class.asp an include in index.asp, then you could pass a querystring value into your sql query in class.asp and select a single record at that level. There are one or two Classic ASP MVCs around. There's one called ASP Extreme Evolution which as far as I can tell writes recordsets into XML objects and then does server side XSL transformations – John Apr 20 '15 at 12:01

0 Answers0