DataSet Problem

  • Thread starter Thread starter Roshawn
  • Start date Start date
R

Roshawn

Hi,

I am using a dataset for a web application. The dataset contains 10 items
when the Products.aspx is loaded. Only 10 items will be shown at a time on
this page. On the page there is a label control placed inside a repeater
control (along with other controls). This label displays the product number
(supposed to be the index of the product).

All works well on the page as product info is displayed to the user.
Whenever I post the page back to the server and add 10 more items to the
dataset, the label control continues to list the product numbers 1-10. It
appears that it isn't continuing the count.

Can anyone help me? Here's my code:

For i = 0 To pinfo.Details.Length - 1 'counts the items on the page

Dim row As DataRow = ds.Tables(0).NewRow

row("No.") = i + 1 'simply count the # of products

row("ProductName") = pinfo.Details(i).ProductName

row("ASIN") = pinfo.Details(i).Asin

row("ListPrice") = pinfo.Details(i).ListPrice

row("OurPrice") = pinfo.Details(i).OurPrice

row("ImageUrlSmall") = pinfo.Details(i).ImageUrlSmall

ds.Tables(0).Rows.Add(row)

Next

Me.Repeater1.DataSource = ds.Tables(0)

Me.Repeater1.DataBind()



The problem appears to be inside the For...Next loop (particularly
row("No.") as I haven't figured out a way to change its behavior)

Thanks for your help

Roshawn
 
Thanks for your response Ryan. Everything works as planned on Page_Load.
The problem occurs when the page is posted back. I know that there is no
code removing items from the dataset. Fortunately, I am using the ViewState
to store small data (like the page numbers). Storing any more than this
would make the page heavy.

Anyway, I think I found the problem. In my code I'm creating a new dataset
each time the page is posted back. That's definitely a problem (and I
didn't include it in my sample code) if not the problem.

I'll let you know how it turned out.

Roshawn
 
Back
Top