Visual Basic Development Bookmark and Share   
 Home > Visual Basic Power Packs > Datarepeater - frustrating!
 

Datarepeater - frustrating!

I know I'm coming off as a whiny-brat but working with this datarepeater control is so frustrating! No matter how much I read about it and how much I try things, I just cannot get it to work like I want. I'm sure most of the problems are my own ignorance. I'm finishing up my 5th day trying to get comboboxes to work in a dr.

I have three main problems currently, two of which I've posted here on this forum but haven't received an answer as yet. The 3rd is that, if there is more than one row in the dr, and all rows have a combobox control, then changing the selection in one combo changes them all. Here is my code. I've noticed that the "For Each s As String..." loop never gets executed. Might thisbe causing the problem and if so, how do I resolve it?

Private Sub PeopleTypes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    LoadComboBox()

    PeopleTypesDatarepeater.BeginResetItemTemplate()

    strSQL = "SELECT * FROM viewPeopleTypes WHERE PeopleID = " & intID
    daPeopleTypes = New SqlDataAdapter(strSQL, connPeopleTypes)
    daPeopleTypes.Fill(dt)
    bs.DataSource = dt

    PeopleTypesDatarepeater.EndResetItemTemplate()
    PeopleTypesDatarepeater.DataSource = bs

    If bs.Count = 0 Then
        btnDelete.Visible = False
    Else
        btnDelete.Visible = True
    End If

End Sub

Private Sub LoadComboBox()

    daPTCombo = New SqlDataAdapter( _
      "SELECT * FROM tlkpPeopleTypes ORDER BY PeopleType", connPeopleTypes)

    'set up People Type combo box
    daPTCombo.Fill(dsPTCombo, "tlkpPeopleTypes")

    cboPeopleType.DataSource = dsPTCombo.Tables("tlkpPeopleTypes")
    cboPeopleType.DisplayMember = "PeopleType"
    cboPeopleType.ValueMember = "PeopleTypeID"
    cboPeopleType.Text = ""

End Sub

Private Sub PeopleTypesDatarepeater_ItemCloned(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) Handles PeopleTypesDatarepeater.ItemCloned

    Dim Source As ComboBox = _
          CType(PeopleTypesDatarepeater.ItemTemplate.Controls.Item("cboPeopleType"), ComboBox)
    Dim ComboBox1 As ComboBox = _
          CType(e.DataRepeaterItem.Controls.Item("cboPeopleType"), ComboBox)

    For Each s As String In Source.Items
        ComboBox1.Items.Add(s)
    Next

End Sub
I've not done much reading about VS2010. Has the dr control improved any? If so, it may worth an upgrade since I can see where I will need this a lot as I convert old Access mdb's to .Net.

Thanks for any help or advice.

kris_hood  Thursday, June 18, 2009 5:26 PM

Hello Kris,

I understand your issue now. It seems the issue is in
ComboBox.DataSoruce = dsPTCombo.Tables("tlkpPeopleTypes") ' A DataTable
It seems all ComboBoxes share a same datasource here and so when you change one it will reflect to others.
I will check with other people to see if this is a bug or not.

For your code bellow:
For Each s As String In Source.Items
ComboBox1.Items.Add(s)
Next
It is expected not working.
When you use the databinding feature (ComboBox.DataSource = ...), then you can not get or set the items.Source.Items
in the code above will return empty collection and so you don't see the code is called.

OK, now here is something that works in my computer, I used Northwind for my sample



Public Class Form1

Private dataLoaded As Boolean = False
Private Sub LoadData()
If (dataLoaded) Then
Return
End If
dataLoaded = True
Me.ProductsTableAdapter.Fill(Me.NorthwindDataSet2.Products)
Me.CategoriesTableAdapter.Fill(Me.NorthwindDataSet2.Categories)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LoadData()
End Sub

Private Sub DataRepeater1_ItemCloned(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) Handles DataRepeater1.ItemCloned
' Ensure data loaded
LoadData()

Dim ComboBox1 As ComboBox = _
CType(e.DataRepeaterItem.Controls.Item("Category_IDComboBox"), ComboBox)
ComboBox1.DataSource = New BindingSource(Me.NorthwindDataSet2.Categories, "")
ComboBox1.DisplayMember = "Category Name"
ComboBox1.ValueMember = "Category ID"
End Sub
End Class

Hope this would help you.

John Chen MS  Friday, July 03, 2009 9:05 AM

Dude not to be rude but please do yourself a favor and get rid of the datarepeater it is a horrible microsoft failure!!!!!! TRUST ME I WAISTED 2 MONTHS WITH THAT CONTROL AND ALMOST LOST MY JOB!!!!!

  •  
Charlieit123  Tuesday, November 24, 2009 4:12 AM

You can use google to search for other answers

Custom Search

More Threads

• Location for Uploading Code Samples?
• embedded Media Player repeat playlist
• Unable to clear datarepeater
• Windows Media Player plugin commands
• Is there a Release date for Power Pack for VB2008?
• DataRepeaterItem with Binding Controls Scroll Problem
• Controls Not Visible on TabPage
• SpeechLib
• moving shapes with mouse at runtime
• alternate the background collor in a DataRepeater