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

[Solved] How to bind data with IEnumerable?

1 Answer 241 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Billy Pham
Top achievements
Rank 1
Billy Pham asked on 12 Aug 2009, 09:44 AM
Hi all,

I tried to bind data in onDataNeed function of a radgrid with IEnumerable as the code below. Remember DisplayComponent is just a temporary class, not a table that I created to store the results. The ExecuteQuery runs without any trouble. However, I cannot bind the to the radgrid. Anyone knows why?

protected void viewBookings_OnNeedDataSource(...) 
            string s_query = "select distinct bk.Start, fi.FacilityName, bk.Username " + 
                              "from Booking_Form as bk, " + 
                                    "Facility_Item as fi " + 
                              "where bk.FacilityID = fi.ID"; 
 
            IEnumerable<DisplayComponent> results = data.ExecuteQuery<DisplayComponent>(s_query); 
 
            viewBookingsGrid.DataSource = results.ToList(); 
 
        public class DisplayComponent 
        { 
            public string FacilityName, Username; 
            DateTime Start; 
 
            public DisplayComponent() 
            { 
            } 
        } 





1 Answer, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 12 Aug 2009, 01:50 PM
Hello Billy,

If the grid does not have columns this is caused by the fact that DisplayComponent class does not have any public properties. FacilityName and Username actually are fields!

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Billy Pham
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or