how to loop through items in a radlistview.

4 posts, 0 answers
  1. DanInMa
    DanInMa avatar
    7 posts
    Member since:
    Aug 2013

    Posted 13 Jun 2014 Link to this post

    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.
    }
    }

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Jun 2014 in reply to DanInMa Link to this post

    Hi DanInMa,

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. DanInMa
    DanInMa avatar
    7 posts
    Member since:
    Aug 2013

    Posted 16 Jun 2014 in reply to Shinu Link to this post

    so there is no way to iterate through them easily like there is with a standard listview?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Jun 2014 in reply to DanInMa Link to this post

    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.
Back to Top