954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ASP Repeat Region and Strings

Hi guys,

I've just managed to get 99% of a script running for my website. I am creating a system where a user can create an invoice using our billing system, and then download it via PDF.

I am using Persists PDF module and I have got it all working. However, there is just one thing I am unable to figure out. I can't seem to repeat a particular part of the string used by the PDF module. I am using dynamic data successfully to populate the data created in the PDF, but my repeat region refuses to repeat my row in the table.

The first row is shown fine in the PDF, but the subsequent rows fail to show.

My code currently looks like this:

...last part of my string"
%>
<%
While ((Repeat1__numRows <> 0) AND (NOT Products.EOF))
%>
<% Body2 = "<tr><td width=""80%"" class=""PicBorder""><div align=""left"" class=""BodyTextSmaller"">" & Products("Name").Value & " - " & Products("BillingCycle").Value & "</div></td><td width=""20%"" class=""PicBorder""><div align=""left"" class=""BodyTextSmaller"">&pound;" & Products("ProductCost").Value & "</div></td></tr>" 
%>
<%
Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Products.MoveNext()
  Wend 
%>
<%
Doc.ImportFromUrl Body & Body2 + "...last part of my final section of my string


I am using ASP VB and MySQL 4 databases. As I said, I have figured out everything on my own so far, but this one has me stumped!

Thanks in advance,
Adam

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

At what stage is the PDF created? Wouldn't it be better to complete the construction of the invoice data and then send to PDF?

ArtistScope
Junior Poster
150 posts since Jun 2010
Reputation Points: 5
Solved Threads: 14
 

Hi there,

Thanks for your reply, but the code does contruct the data first, and then sends it to the PDF create command. The trouble is, I have to break up the string in order to get the repeat region code to work.

Regards,
Adam

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Any ideas guys? :)

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

**bump**

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This looks like code intended for pagination of results, and not record rows.

ArtistScope
Junior Poster
150 posts since Jun 2010
Reputation Points: 5
Solved Threads: 14
 

Hi AS,

The code is normally used to displays the rows in a table, based on the criterea of the recordset. The code usually works when used in normal conditions but not when already in a ASP script that uses a string.

Any ideas? Many thanks.

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Line 9-12 are unnecessarily complicated. Better to use a simple row return. No increment or count is required...

if not rsProduct.EOF then
   response.write" Your row stuff"
end if
ArtistScope
Junior Poster
150 posts since Jun 2010
Reputation Points: 5
Solved Threads: 14
 

Hi AS,

Thanks for your help.

As far as I know the code you suggested wouldn't repeat the rows in the table one after another would it?

The code I'm using is a repeat region, and I want the code to display multiple rows that are based from the criterea in the recordset.

Do we have our wires crossed somewhere? I do appreciate the help though :)

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

It will return every row that meets the criteria. For example...

response.write"<table>"

SQLAuthor = "SELECT * FROM Users Order By ID ASC "
Set rsAuthor = dbConnection.Execute(SQLAuthor)	
if NOT rsAuthor.EOF then

response.write"<tr>"
response.write"<td>" & rsAuthor("ID").value & "</td>"
response.write"<td>" & rsAuthor("Author").value & "</td>"
response.write"<td>" & rsAuthor("Firstname").value & "</td>"
response.write"<td>" & rsAuthor("Lastname").value & "</td>"
response.write"<td>" & rsAuthor("Active").value & "</td>"
response.write"</tr>"

end if
rsAuthor.Close
Set rsAuthor = Nothing

response.write"</table>"


The above example will return a table row for every author in the database.

ArtistScope
Junior Poster
150 posts since Jun 2010
Reputation Points: 5
Solved Threads: 14
 

I fixed an error but now cannot delete this post :-(

ArtistScope
Junior Poster
150 posts since Jun 2010
Reputation Points: 5
Solved Threads: 14
 

Hi AS,

Would that interfere with the string? The data I have is a string and cannot be broken. That's the trouble with it you see because the whole HTML is a string, the ASP also needs to be put into the string which is causing me problems. If this was a normal page I wouldn't need to ask for help hehe.

I'm trying to get working the ASP PDF component and got everything working dynamically apart from the repeat region.

Many thanks,
Adam

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This is not a string...

While ((Repeat1__numRows <> 0) AND (NOT Products.EOF))....


But it is a lot of unnecessary code that can be replaced using the simple example that I gave.

Try it.

ArtistScope
Junior Poster
150 posts since Jun 2010
Reputation Points: 5
Solved Threads: 14
 

Hi AS,

I tried the code you suggested, but I didn't specify the recordset becuase that has already been done above.

Once I updated the code with your code, no rows appear at all. I now have this code below:

height=""30"" class=""PicBorder""><div align=""left"" class=""BodyTextSmall""><strong>Amount</strong></div></td></tr>"

While ((Repeat1__numRows <> 0) AND (NOT Products.EOF))

If NOT Products.EOF then

Response.write"<tr>"
Response.write"<td width=""80%"" class=""PicBorder"">"
Response.Write"<div align=""left"" class=""BodyTextSmall"">" & Products.Fields.Item("MoreInfo").Value & " - " & Products.Fields.Item("BillingCycle").Value & "</div>"
Response.write"</td>"
Response.write"<td width=""20%"" class=""PicBorder"">"
Response.write"<div align=""left"" class=""BodyTextSmall"">&pound;" & Products.Fields.Item("ProductCost").Value & "</div>"
Response.write"</td>"
Response.write"</tr>"

end if
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Products.MoveNext()
Wend 

Doc.ImportFromUrl Body & Body2 + "</table><img src=""http://www.silverlinewe


Any ideas? Have I done something wrong?

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This is not what I recommended at all. It should not include wend, repeat, etc. It's not needed.

ArtistScope
Junior Poster
150 posts since Jun 2010
Reputation Points: 5
Solved Threads: 14
 

Hi,

This is the code I have now. As I said I do not need the code for the recordset as it has already been defined above the code.

</div></td></tr>"

If NOT Products.EOF then

Response.write"<tr>"
Response.write"<td width=""80%"" class=""PicBorder"">"
Response.Write"<div align=""left"" class=""BodyTextSmall"">" & Products.Fields.Item("MoreInfo").Value & " - " & Products.Fields.Item("BillingCycle").Value & "</div>"
Response.write"</td>"
Response.write"<td width=""20%"" class=""PicBorder"">"
Response.write"<div align=""left"" class=""BodyTextSmall"">&pound;" & Products.Fields.Item("ProductCost").Value & "</div>"
Response.write"</td>"
Response.write"</tr>"

end if

Doc.ImportFromUrl Body + "</table>


I appreciate your help.

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

how i can do for you, but 顶……

jie7412
Newbie Poster
3 posts since Nov 2010
Reputation Points: 10
Solved Threads: 0
 
how i can do for you, but 顶……


Sorry?

Your post makes no sense.

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Hi,

Does any one have a solution? I am still searching for a way to get this working. Will no one else help me? Any suggestions, please?

Regards,
Adam

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

Hi,

Does any one have a solution? I am still searching for a way to get this working. Will no one else help me? Any suggestions, please?

Regards,
Adam

spence89
Light Poster
35 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
 
View similar articles that have also been tagged: