Help with repeater & DataBinder.Eval please!!!

New2VBnet

New member
Joined
Aug 23, 2005
Messages
2
Programming Experience
Beginner
I have been asking this question all over the net and no one has an answer -- is it so simple no one wants to touch it???
My question is about the use of a Reapeater to load results from to 2 different tables. Heres what I mean. DataBinder.Eval1 should display Products Name from Products table, DataBinder. Eval2 should display ProductTypes from ProductType Table.
They should load for selection one at a time, Example:
Product: Shampoo: Productypes: Normal, Oily Hair, Dry Hair (selected with
radion buttons) -- click Next Button to select another Product with its
Product Types and so on ---- click Prev Button to look and/or change previous
selection. I'm using 2 seperate queries to load Products and Product types dynamically so not to have a limited number of Product types. This works fine
when loading all Products with respective Product types on one page but can't get it to load one Product with its respective ProductTypes at a time. I found some paginp examples that do the trick but only diplay the Products table(first query).
What I got so far: Products load with DataBinder.Eval1 on Repeater1 and I'm
able to Next and Prev but the Products type do not load per gives Product
types not part of Product table error. So I added Repeater2 to handle
DataBinder.Eval2 and it loads 1 Product(Repeater1) with ALL the product types from every product(Repeater2) instead of just the respective product types.

Below is code so far. Function is from paging example I found and rest from bits and pieces from several asp.net book.

PublicFunction getTheData() As DataTable

DBAdapter = New OleDbDataAdapter _
("Select ProductID, ProductName " _
& "From Products", DBConn)
DBAdapter.Fill(dsData, "Products")


'Retrieves the Products
For I = 0 To dsData.Tables("Products").Rows.Count - 1

'Create literal control to post products
Dim lcHTML = New LiteralControl
lcHTML.Text = "<b><br>" _
& dsData.Tables("Products").Rows(I).Item("ProductName") & "</b><br>"

'Load data into Repeater
Repeater1.Controls.Add(lcHTML)

'Create RadioButtonList and TempID for ProductTypes

Dim MyRBL = New RadioButtonList
TempID = dsData.Tables("Products").Rows(I).Item("ProductID")
MyRBL.ID = "P" & TempID

DBAdapter =
New OleDbDataAdapter _
("Select ProductTypes " _
& "From ProductTypes Where ProductID = " _
& TempID, DBConn)
DBAdapter.Fill(dsData, TempID)

'Load ProductTypes

For J = 0 To dsData.Tables(TempID).Rows.Count - 1

Dim MyItem = New ListItem
MyItem.Text = dsData.Tables(TempID).Rows(J).Item("ProductTypes")
MyDDL.Items.Add(MyItem)

Next

Repeater2.Controls.Add(MyDDL)

'Put ProductTypes in Literal Control
Dim lcHTML2 = New LiteralControl
lcHTML2.Text = "<br><br>"
Repeater2.Controls.Add(lcHTML2)

Next

'This is for Pager
Return dsData.Tables("Products").Copy
EndFunction

Any sharp minds willing to lend a hand or maybe a code snippet or 2 ---- Please!
 
Last edited:
Back
Top