1

I have a DataRepeater (Microsoft.VisualBasic.PowerPacks) which has 100+ records consisting of about 5 TextBoxes and corresponding labels in each item so that it becomes scrollable. In case it matters, its DataSource is set via this line:

repeater.DataSource = myDataSet.Tables["TableName"];  

The weird thing is this: When I add a new row to this DataRepeater (repeater.AddNew()), it brings the new field at the bottom into focus, but it appears to have copied data from another item. It does not appear to always be the same item. Also, if I am at the bottom of the DataRepeater without anything in the new item focused and scroll away and back again, there is (potentially) different data from yet another random item.

I'm basically at a loss at this point. There is no scroll event that could be causing this, and this change to the item happens without triggering a single event/method of either the DataRepeater or the parent user control.
Has anyone experienced similar issues or have an ides of what could cause this behavior?

Update: Adding multiple new items seem to result in them getting their data from consecutive existing items (ex. 3 new items might show data from items 100-102, scroll away and back again, now they might show data from items 150-152)

Code Stranger
  • 103
  • 1
  • 10
Broots Waymb
  • 4,713
  • 3
  • 28
  • 51

1 Answers1

0

You may want to add the newrow to your dataset's table, repeater will update at runtime.

Damien
  • 40
  • 4
  • 1
    You are partially correct, as this was part of the fix we discovered just minutes prior to seeing this. For some reason it still fills in garbage. We have narrowed down the to the repeater possibly not liking null values. If we explicitly handle empty values appropriately and set defaults (usually `""`), it appears to behave correctly. – Broots Waymb Oct 08 '15 at 18:21
  • If you'd like to elaborate on your answer with some additional detail from my above comment (and possibly a short code snippet) I'll gladly accept this as an answer. I probably shouldn't post my findings as an answer as you technically beat me to it. – Broots Waymb Oct 08 '15 at 18:23
  • are you talking about binding to a dataview instead of your table directly? I'm having a hard time guessing the code you wrote, please be more precise. – Damien Oct 09 '15 at 16:28
  • The binding didn't change. I just had to modify the table as you suggested, but also had to supply default field values since the repeater apparently handles null field values oddly. – Broots Waymb Oct 09 '15 at 16:30
  • okay, this is weird... so either set the default value to String.Empty, or check for value != null before adding a new row – Damien Oct 09 '15 at 16:45
  • Basically. Empty handles most cases. I have to check against the field type since numeric values can't be a string. 0 works in those cases. – Broots Waymb Oct 09 '15 at 16:49
  • please update your question with detailed code, so it can be usefull to someone else – Damien Oct 13 '15 at 12:01