I am trying to loop through each item in a radlistview, not just the selected item. I have been tying to figure this out based on examples for standard listviews. This is how I've been shown to do it in a normal listview:
foreach (ListViewItem itemRow in this.ListView.Items)
{
for (int i = 0; i < itemRow.SubItems.Count; i++)
{
// Do something useful here !
// e.g 'itemRow.SubItems[count]' <-- Should give you direct access to
// the item located at co-ordinates(0,0). Once you got it, do something
// with it.
}
}
                                foreach (ListViewItem itemRow in this.ListView.Items)
{
for (int i = 0; i < itemRow.SubItems.Count; i++)
{
// Do something useful here !
// e.g 'itemRow.SubItems[count]' <-- Should give you direct access to
// the item located at co-ordinates(0,0). Once you got it, do something
// with it.
}
}
5 Answers, 1 is accepted
0
                                
                                                    Shinu
                                                    
                                            
    Top achievements
    
            
                
                Rank 2
            
    
                                                
                                                answered on 16 Jun 2014, 05:50 AM
                                            
                                        Hi DanInMa,
Please try to looping through the RadListView Items collection and try finding the desired item as follows.
C#:
Let me know if you have any concern.
Thanks,
Shinu.
                                        Please try to looping through the RadListView Items collection and try finding the desired item as follows.
C#:
protected void rbtnGetItems_Click(object sender, EventArgs e){    string idofProduct = string.Empty;    foreach (RadListViewItem item in rlstvProducts.Items)    {        Label productId = item.FindControl("lblProductId") as Label;        idofProduct = productId.Text;        //your code    }}Let me know if you have any concern.
Thanks,
Shinu.
0
                                
                                                    DanInMa
                                                    
                                            
    Top achievements
    
            
                
                Rank 1
            
    
                                                
                                                answered on 16 Jun 2014, 05:35 PM
                                            
                                        so there is no way to iterate through them easily like there is with a standard listview?
                                        0
                                
                                                    Shinu
                                                    
                                            
    Top achievements
    
            
                
                Rank 2
            
    
                                                
                                                answered on 17 Jun 2014, 04:54 AM
                                            
                                        Hi DanInMa,
This is the best method top loop through items in RadListView. Due to the virtualization mechanism of RadListView, the visual items are reused for displaying different data items. So this the best method to looping through the RadListView Items collection and find the control.
Thanks,
Shinu.
                                        This is the best method top loop through items in RadListView. Due to the virtualization mechanism of RadListView, the visual items are reused for displaying different data items. So this the best method to looping through the RadListView Items collection and find the control.
Thanks,
Shinu.
0
                                
                                                    Monique
                                                    
                                            
    Top achievements
    
            
                
                Rank 1
            
                
                    
                    Iron
                
    
                                                
                                                answered on 17 Jul 2019, 06:39 PM
                                            
                                        I'm able to do this
            radCheckedListBox1.Items.Clear();
            foreach (FileInfo fileName in di.EnumerateFiles())
            { 
                    radCheckedListBox1.Items.Add(fileName.FullName.ToString());            
            }
But I'm getting a Namespace error here:
            foreach (RadListViewItem item in radCheckedListBox1.Items)
                    {
The namespace RadListViewItem cannot be found. Please help.
1
                                Hello Monique,
To resolve the Namespace issue, please addTelerik.Web.UI in the using section:
using Telerik.Web.UI;Also, if the radCheckedListBox1 is actually a RadListView, you can also use the RadListViewDataItem class which inherits the RadListViewItem.
foreach (RadListViewDataItem item in listview.Items)
{
    // your code here
}Regards,
 Peter Milchev
 Progress Telerik
    
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
