Solved

populating an MSFlexgrid

Posted on 2003-12-03
3
388 Views
Last Modified: 2010-04-20
Take a look at the following code, basically all I'm doing is getting a session variable from another page and converting it to a standard variable. Then creating an array to populate an MSFlexGrid.

When I try to run the code as the page loads I get an error message Object Required G was not handled, (G is the name of my MSFlexGrid)

However, if I place this code in a sub, the page loads first and then I execute the code and it works fine - presumably because my MSFlexGrid (G) exists on the page, where as it doesn't in the earlier scenario.

How can I populate this grid when the page loads and remove the need for a click event.

Looking forward to your help.

Matt.

<SCRIPT LANGUAGE=vbscript>
Dim retVar
Dim i
Dim j
Dim SessConv
Dim a
Dim pos
Dim z
Dim w
Dim max    ' max number of elements
Dim count
   
SessConv = "<%=session("ses_search")%>"

    ReDim a(<%=session("ses_FirstDimUBound")%>, <%=session("ses_SecondDimUBound")%>)
    max = (UBound(a, 1) - LBound(a, 1) + 1) * (UBound(a, 2) - LBound(a, 2) + 1)
    count = 0
           
    For I = LBound(a, 2) To UBound(a, 2)
        ' Process 2nd dimension element for each 1st dimension values
        For J = LBound(a, 1) To UBound(a, 1)
            count = count + 1
            If count > max Then
                Exit For
            Else
                pos = InStr(SessConv, "#")
                if pos = 0 then
         a(J, I) = ""
                else
         a(J, I) = Left(SessConv, pos - 1)
                end if                
                SessConv = Mid(SessConv, pos + 1)
            End If
        Next
       
        If count > max Then Exit For
    Next
      
       retVar = a 'at this point retvar contains all the required data in an array

g.Rows = UBound(retVar, 2) + 1 ' code fails here on the 1st ref to g
g.Cols  = UBound(retVar, 1) + 1
g.FixedCols=0
g.FixedRows=1

for z=0 to g.Cols - 1
      g.TextMatrix(0, z) = "Column #" & z
      g.ColAlignment(z) = flexAlignRightCenter
      g.ColWidth(z) = 2000      
next
'g.width = g.ColWidth(0) + g.ColWidth(1) + g.ColWidth(2) + g.ColWidth(3) + g.ColWidth(4) + g.ColWidth(5)


      for z = g.FixedRows to g.Rows - 1
            for w = g.FixedCols to g.Cols - 1
                  g.TextMatrix(z, w) = retVar(w, z)

            next
      next
</SCRIPT>
0
Comment
Question by:Matt_Unsworth
  • 2
3 Comments
 
LVL 9

Expert Comment

by:fz2hqs
ID: 9873110
"Then creating an array to populate an MSFlexGrid" - not in ths code snippet, there is no creating
0
 

Author Comment

by:Matt_Unsworth
ID: 9873136
Good point, the array is created in the previous page and passed to this page as a string.

The value retvar contains what I want but the problem still stands of populating g, any ideas how I can do this.

I think that g does not exist when I try to populate it in the code above, how can I get around this.

Matt.
0
 
LVL 9

Accepted Solution

by:
fz2hqs earned 500 total points
ID: 9873150
If the object is created in the last page, then it is also destroyed at the end of execution of the last page. You need quite simply to create G within this page you can pass values in string form but you will have to create it here

PS - You may want to avoid naming variables like you do, it is far easier for everybody (yourself included) if you try naming things like intLoopCount, grdMyFlexiGrid  - a's b's and z's are meaningless and make reading code difficult
0

Featured Post

New My Cloud Pro Series - organize everything!

With space to keep virtually everything, the My Cloud Pro Series offers your team the network storage to edit, save and share production files from anywhere with an internet connection. Compatible with both Mac and PC, you're able to protect your content regardless of OS.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CGI takes almost 2 minutes to load using thttpd 20 44
Use System DSN 6 84
SSL sertificate 5 58
In IIS redirect browser clients that do not support TLS 1.2 to another site 3 81
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now