This is a migrated thread and some comments may be shown as answers.

Simple loop to retrieve sub-items in ListView

1 Answer 1387 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 17 Apr 2015, 03:32 PM

Hi folks.

I have a list view which can be populated with many rows of data (not databound)

Once populated I want to grab the text values of certain sub items - but the ListViewDataItem does not have a subitem property

EG:

foreach (ListViewDataItem item in radListViewPOItem.Items)

{
                    
}

Any tips on how to accomplish a simple task?

Thanks.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Ralitsa
Telerik team
answered on 21 Apr 2015, 07:05 AM
Hi Martin,

Thank you for contacting us. 

I suppose that you use the ListViewType.DetailsView and want to get the value of specific column. Here is the code snippet: 
foreach (ListViewDataItem item in this.radListView2.Items)
{
    if (item["Column1"].ToString() == "CellValue1 3")
    {
        this.radLabel2.Text = "Text: " + item.Text + "\nValue " + item.Value;
    }
}

In the attachment you can find a sample demo. 

If this is not what you want to achieve, I would kindly ask you to send me a more detailed explanation how you add the list items and which text you want to get. 

Let me know if I can assist you further.

Regards,
Ralitsa
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
ListView
Asked by
Martin
Top achievements
Rank 1
Answers by
Ralitsa
Telerik team
Share this question
or