Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving through datarepeater's items

Is there any way to move through datarepeater's items through code, as we run loop and move through the items in a list / combo box? Thanks Furqan

like image 694
Furqan Sehgal Avatar asked Feb 26 '23 08:02

Furqan Sehgal


2 Answers

The code from Schmelter changes the current row, but this might produce undesired effects since it can update the UI and causes other data-handling events to fire. It's not necessary to change the CurrentItemIndex to loop through the DataRepeaterItems. Each DataRepeaterItem is just a Control object in the DataRepeater.Controls collection. Here is an alternative (in C#):

    using Microsoft.VisualBasic.PowerPacks; 
    foreach ( DataRepeaterItem rowItem in dataRepeater1.Controls )
    {
        int itemIndex = rowItem.ItemIndex;

        // If it's bound, get the underlying data object
        object dataItem = BindingSource1.List[itemIndex];

        // Add code for each rowItem of the dataItem
        // All controls on the DataRepeateItem can be obtained from rowItem.Controls  
    }
like image 191
C Perkins Avatar answered Mar 12 '23 22:03

C Perkins


This should work:

   For i As Integer = 0 To Me.DataRepeater1.ItemCount -1
       Me.DataRepeater1.CurrentItemIndex = i
       Dim item As DataRepeaterItem = Me.DataRepeater1.CurrentItem
   Next
like image 25
Tim Schmelter Avatar answered Mar 12 '23 23:03

Tim Schmelter