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

list of complex objects as datasource

2 Answers 125 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
ted
Top achievements
Rank 1
ted asked on 23 Aug 2011, 04:36 PM
I want to try and use a list of objects as my data source where the object contains multiple fields and I am populating the listbox programmatically.  If I set the Datasource of my list box to the object how can I set what fields actually show up in the listbox I tried using templates but I couldn't get that to work.

List<Keyword> resultList = keywordService.FindKeywords();
            canonicalSearchResults.DataSource = resultList;
            canonicalSearchResults.DataBind();

I want the Keyword's name field to appear in the textbox but be able to keep the datasource as a list of keywords so that I can later access them. Right now it calls the tostring method and displays the result but the toString method is different than what I want displayed

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter Filipov
Telerik team
answered on 26 Aug 2011, 10:04 AM
Hello Ted,

Please review the following resources: demo for declarative datasource binding and the attached project(example with templates).

All the best,
Peter Filipov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
ted
Top achievements
Rank 1
answered on 26 Aug 2011, 03:36 PM
Thanks I just needed to know the right place to look
Tags
ListBox
Asked by
ted
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
ted
Top achievements
Rank 1
Share this question
or