VB.net troubleshooting Data repeater when scrolling

259 views Asked by At

I use a Data Repeater (name DR_listMembers) with virtual mode = true on the item template of Data Repeater are two controls TextBox1 and PictureBox1

I add five items and fill the controls with some text and picture

But when i scroll the data repeater that erase the value of both pictureBox and textBox !

Here is the way i fill the controls.

For id = 0 To 5
  DR_listMembers.AddNew()
  DR_listMembers.CurrentItem.Controls("TextBox1").Text = id.ToString
  DR_listMembers.CurrentItem.Controls("PictureBox1").BackgroundImage = System.Drawing.Image.FromFile(fichierINI.getParamFileINI("chemins", "images") & "Troops\" & "Barbarian - 1.png")
Next

Does anybody know why and give the way to solve that !

Thanks

1

There are 1 answers

0
Sebastien On

I have my answer. In virtual mode, data in datarepeater need to be refresh.

Use the ItemValueNeeded notification to refresh datas

Private Sub DR_listMembers_ItemValueNeeded(sender As Object, e As PowerPacks.DataRepeaterItemValueEventArgs) Handles DR_listMembers.ItemValueNeeded

    Dim id As Integer = e.ItemIndex

    Select Case e.Control.Name
        Case "TextBox1"
            e.Value = id.ToString
        Case "PictureBox1"
            e.Value = System.Drawing.Image.FromFile(fichierINI.getParamFileINI("chemins", "images") & "Troops\" & "Barbarian - 1.png")

    End Select

End Sub