3.2.0

Using Classic ASP - Can't Get Grid to Display

I would love to pay to use this software but until I can get it to work... I simply cannot get the grid to display in a browser (I've tested on Firefox, IE, even Safari in case it was a browser issue) - here's my code for classic ASP - can anyone tell me what I'm doing wrong? I've scoured the Forum, I've looked at documentation, I'm stumped (and I'm sure it's something basic I've overlooked) - any help would be greatly, greatly appreciated!

<%@LANGUAGE="VBSCRIPT"%>
<!--#include virtual="/Nav/Include.inc"-->
<!--#include virtual="/Connections/conn_SQL_Site.asp" -->

<%

Dim oRecordset
Dim oRecordset_cmd
Dim oRecordset_numRows

Set oRecordset_cmd = Server.CreateObject ("ADODB.Command")
oRecordset_cmd.ActiveConnection = MM_conn_SQL_Site_STRING
oRecordset_cmd.CommandText = "SELECT * FROM dbo.Pictorials_Pictorial ORDER BY AEMID ASC"
oRecordset_cmd.Prepared = true

Set oRecordset = oRecordset_cmd.Execute

' encodes control characters for javascript
function aw_string(s)

s = Replace(s,"\","\\")
s = Replace(s,"""","\""") 'replace javascript control characters - ", \
rem s = Replace(s,vbCr,"\r")
rem s = Replace(s,vbLf,"\n")

aw_string = """" & s & """"

end function

' returns the field names from the recordset formatted as javascript array
function aw_headers(oRecordset)

Dim i, count, headers()

count = oRecordset.fields.count
ReDim headers(count-1)

For i=0 to count-1
headers(i) = aw_string(oRecordset(i).name)
Next

Response.write("[" & Join(headers, ", ") & "];")

end function

' returns the recordset data formatted as javascript array
function aw_cells(oRecordset)

Dim i, col_count, row_count, columns(), rows()

row_count = 0
col_count = oRecordset.fields.count
ReDim columns(col_count-1)

Do while (Not oRecordset.eof)

For i=0 to col_count-1
columns(i) = aw_string(oRecordset(i))
Next

ReDim preserve rows(row_count)

rows(row_count) = vbTab & "[" & Join(columns, ", ") & "]"
row_count = row_count + 1

oRecordset.MoveNext
Loop

Response.write("[" & vbNewLine & Join(rows, "," & vbNewLine) & vbNewLine & "];" & vbNewLine)

end function

%>
<html>
<head>
<body>
<title>ActiveWidgets Examples</title>
<style>body {font: 12px Tahoma}</style>

<!-- include links to the script and stylesheet files and I do have everything foldered in the same place -->
<script src="aw.js"></script>
<link href="aw.css" rel="stylesheet" />

<!-- change default styles, set control size and position -->
<style>
#myGrid {height: 500px}

</style>
</head>
<body>
<h3>ASP classic - VBScript, ADO</h3>
<p>Make VBScript functions returning the data formatted as javascript arrays,<br />
Insert the results inside Javascript data block - test</p>
<p><%=(oRecordset.Fields.Item("title").Value)%></p> This displays so I am connecting to the dbase


<!-- insert control tag -->
<span id="myGrid"></span>
<!-- add data block -->
<%= aw_headers(oRecordset) %> I can see this output
<%= aw_cells(oRecordset) %>I cannot see this output
<script language="JavaScript">
// insert javascript arrays produced by ASP functions
var myHeaders = <%= aw_headers(oRecordset) %>
var myCells = <%= aw_cells(oRecordset) %>



// create grid control
var grid = new AW.UI.Grid;

// assign the grid id (same as placeholder tag above)
grid.setId("myGrid");

// set grid text
grid.setHeaderText(myHeaders);
grid.setCellText(myCells);
//grid.setCellText(true);
grid.setCellEditable(true);
// set number of columns/rows
grid.setColumnCount(myHeaders.length);
grid.setRowCount(myCells.length);

// write grid to the page

obj.setCellText(myCells);
obj.setColumnCount(4);
obj.setRowCount(5);


grid.refresh();


</script>

</body>
</html>
<%
oRecordset.close

%>
lb1
February 20,
Unfortunately I do not have time to go through your code. But I can assure you it works fine with classic ASP, that is how I am using it.

There is perhaps too much going on here, could be a problem unrelated to ActiveWidgets.

Try simplifying and building up from there. Get rid of the recordset and database stuff and just put dummy constant data in. Once you get the grid displaying, take it from there.

Do not know how new you are, so don't be insulted. But the most common database related problem is having an apostrophe in your data (') which messes up SQL.
Eric J.
February 20,
I appreciate your help, Eric! I'm able to connect to the database, I'm able to output data on the page using my SQL statement, I keep thinking it has to do with the ActiveWidgets function for the grid cells. Per the code above (sorry about all the code):

<%= aw_headers(oRecordset) %> I can see this output
<%= aw_cells(oRecordset) %> I cannot see this output

But so many folks are taking the classic ASP code supplied by ActiveWidgets and NOT having any issues as they test it out so that's why I'm stumped - I pretty much copy and pasted their code and simply tweaked to work my connection string info in, etc. I like your idea about simplifying with dummy data - I'll give it a go. Thanks again!
lb1
February 23,
I put in static dummy data and the grid shows fine (thanks again Eric!) - so my paths to the .js file and .css file are fine. To be even more specific here's where things break down:

Response.write("[" & Join(headers, ", ") & "];") - this line for the column header outputs my data but not anywhere else, not even in the web page body..

Response.write("[" & vbNewLine & Join(rows, "," & vbNewLine) & vbNewLine & "];" & vbNewLine) - this line for the cells does not output anywhere...

As I mentioned, I copy and pasted the recc code from the AW download - what could be the problem? Anybody?
lb1
February 23,
So I've narrowed it all down to this - the headers are coming in perfectly from the SQL dbase to the web page into the grid headers area. But the cells simply aren't showing - if I use static data for the cells in the web page then I get the grid. Again, any thoughts anybody on why the cell data doesn't make it through? I've tried simplifying the SQL query, I've changed everything to connect to an Access dbase with the same result... header data but no cell data...
lb1
February 23,
ASP only issues never resolved, have implemented AW successfully using XML (using ASP to retrieve data).
lb1
February 27,

This topic is archived.

See also:


Back to support forum