Building data grid (table)

Results 1 to 3 of 3

Thread: Building data grid (table)

  1. #1
    Roger Paini Guest

    Default Building data grid (table)

    Hi everybody<BR><BR>I was just reading through the posts when I found this link:<BR><BR><BR><BR>There Bill Wilkinson wrote:<BR>"Almost the biggest mistake you can make--and yet the method that we tend to most often see beginners attempting--is to open up the first table and then, as you move to each new record in that table, open up another recordset where you select only the subcategory records that match the given category. "<BR><BR>Ok, now here&#039;s my problem:<BR>I want to build a data grid. Below you find some sample data:<BR><BR>Area¬*¬*¬*¬*Phase¬*¬*¬*¬*Project<BR>¬ *UK¬*¬*¬*¬*¬*¬*Ph1¬*¬*¬*¬*¬*¬*Bird<BR>¬*UK¬*¬*¬*¬* ¬*¬*Ph1¬*¬*¬*¬*¬*¬*Mouse<BR>¬*US¬*¬*¬*¬*¬*¬*Ph1¬*¬ *¬*¬*¬*¬*Dog<BR>¬*US¬*¬*¬*¬*¬*¬*Ph2¬*¬*¬*¬*¬*¬*Cat <BR>¬*CH¬*¬*¬*¬*¬*¬*Ph2¬*¬*¬*¬*¬*¬*Elephant<BR><BR ><BR>The grid (table) should have the Area at the left and the phases at the top (area versus phases). In the fields I like to have the projects (sample grid below; please look at it with courier font). <BR><BR>¬*¬*¬*¬*¬*¬¶¬*¬*Ph1¬*¬*¬*¬¶¬*¬*¬*¬*Ph2¬*¬* ¬*¬*¬*¬¶<BR>¬*¬*---+--------+------------+<BR>¬*¬*UK¬*¬¶¬*¬*Bird¬*¬*¬¶¬*¬*¬*¬*¬*¬*¬*¬*¬*¬*¬ *¬*¬¶<BR>¬*¬*¬*¬*¬*¬¶¬*¬*Mouse¬*¬¶¬*¬*¬*¬*¬*¬*¬*¬* ¬*¬*¬*¬*¬¶¬*<BR>¬*¬*---+--------+------------+<BR>¬*¬*US¬*¬¶¬*¬*Dog¬*¬*¬*¬¶¬*¬*Cat¬*¬*¬*¬*¬*¬*¬ *¬¶<BR>¬*¬*---+--------+------------+<BR>¬*¬*CH¬*¬¶¬*¬*¬*¬*¬*¬*¬*¬*¬¶¬*¬*Elephant¬*¬*¬ ¶<BR>¬*¬*---+--------+------------+ <BR><BR>Now I have not 3 areas as in the sample above but 12 and not 2 phases but 10. <BR>Currently I loop through the areas and phases and open for each variation (e.g. UK/Ph1, UK/Ph2...) a recordset. That means, I have to request 120 times a new recordset which is not very fast. Did you ever come accross such a problem? I think I can&#039;t use the procedure Bill described in his answer because I need a table... Any ideas?<BR><BR>Thanks<BR>Roger<BR><BR>PS: to Bill Wilkinson: you do a great job - I always like reading your answers ;-)

  2. #2
    Join Date
    Dec 1969

    Default Not sure...

    ...but this may help get you started...<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Building data grid (table)

    Get one big recordset, but order it in an appropriate way.<BR><BR>For instance:<BR>SELECT Area, Phase, Project FROM Table ORDER BY Area, Phase<BR><BR><BR>Then you get your recordset like this:<BR>Area Phase Project<BR> CH Ph2 Elephant<BR> UK Ph1 Bird<BR> UK Ph1 Mouse<BR> US Ph1 Dog<BR> US Ph2 Cat<BR><BR>Now just loop through your recordset.<BR>Something like this:<BR><BR>Dim strPrevArea, strPrevPhase<BR><BR>Response.write "&#060;table&#062;&#060;tr&#062;"<BR><BR>Do While not RS.EOF<BR> If strPrevArea &#060;&#062; RS.Fields("Area").value AND strPrevPhase &#060;&#062; RS.Fields("Phase").value Then<BR> &#039; next row in table<BR> Response.write "&#060;/tr&#062;&#060;tr&#062;"<BR> End If<BR> <BR> Response.write "&#060;td&#062;" & RS.Fields("Project").value & "&#060;/td&#062;<BR> <BR> strPrevArea = RS.Fields("Area").value<BR> strPrevPhase = RS.Fields("Phase").value<BR> RS.MoveNext<BR>Loop<BR><BR>Response.write "&#060;/tr&#062;&#060;/table&#062;"<BR><BR>This won&#039;t get your values in the correct columns, but you can write some code for that. This should get you started...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts