Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display multiple records with a dynamic structure

Status
Not open for further replies.

agoodrich

MIS
Jul 13, 2004
37
US
How could I code somthing in asp to choose a table structure dynamicly then loop through multiple records and display them with this structure on my page. I would like these table structures to be stored on seperate files.

I also want to know how to display these records in word format right in the browers windows. But I don't know where to start. Any suggestions.
 
Sure... On my page I will login and go to the search page. On the search page it will have a printable link. That link takes me to a page that uses requests to open the database, pull the records I need then display the table differently depending on who I am.

I just want to have some template files that contain only the table code depending on who I am.
<table>
<tr>
<td>object requests to fill in the tables</td>
</tr>
</table>

I want this code to loop through for the number of records selected and display the tables in a column on the page seperated by a print page break using a header. I already know how to do the print break part.
 
You could build your differant tables and put them in include files then do a case statement based on the template name you have stored for that user:
Code:
'not sure where your getting this, I'm making it up
Select Case rs("user_template")
   Case "Template 1"
      ><!--#INCLUDE FILE="templates/template1.inc" --><%
   Case "Template 2"
      ><!--#INCLUDE FILE="templates/template2.inc" --><%
   Case Else
      ><!--#INCLUDE FILE="templates/default_template.inc" --><%
End Select

Then each template file would just have the code to generate the table from the recordset you created in your main file. The cool thing about this is that it would be fairly easy to add a new template simply by adding a new include file and case in the case statement.


Now, if the data was going to be laid out the same way everytime and you just wanted to change the color scheme, font, etc I would suggest just having differant CSS files and storing the name of the CSS file in their template field.

-T
-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
I thought about using the case way...

But I have 8 or more templates that I will be using. Won't that slow down the page if it has to load all those templates before it displays the one I want on the screen?
These templates are fullpage tables that contain on average 50 rows and 2 colunms.

Right now I'm setting it up so that the print page link is dynamic and just points you to the processing file with the correct <!-- insert page --> for each unique template. That means that I will have to have a processing file for template but the only thing in the processing file that will change is the <!-- insert page -->.

This should work Till I figure out how to just merger the data right to a word doc on the users screen.
 
yes it would slow it down some to have all of those pages included, but it shouldn't be excesive and may be the only solution short of doing Server.Transfers (like Response.Redirect except it is server-side so you don't lose form info).

On the other hand, I have some asp files (I hesitate to call them pages) that are in excess of 1000 lines. It's not the best way to build, but I like embedding multiple pages in one file. Take my homepage for instance, the current front site (old site) is 1045 lines in the main file, then includes approximately 1000 lines more of include files.
T's website

If you want to see some raw numbers for load times, I have a sub-site setup for half-life statistics that has total of about 1200 lines and also reports server processing time: Some HL stats

So yes lots of code dos cause a pageto execute slower, but I have yet to find a site that is noticeably slower for just a few hundred more lines of code.

-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top