Search code examples
c#datasourceradgridviewbindinglist

Problem while filling a RadGridView with a BindingList of objects


I need some help on a little problem; I want to use a component which inherits from a RadGridView from Telerik.
I want to fill it with a BindingList of RowService, a class I create, the code looks like this :

public class RowService
    {
        public String ServiceName { get; set; }
        public String Description { get; set; }
        public ServiceControllerStatus ServiceStatus { get; set; }
        public String State { get; set; }
        public ServiceStartModeEx StartMode { get; set; }
        public String StartType { get; set; }
        public String StartName { get; set; }
        public String PathName { get; set; }
        public String Version { get; set; }
        public String NewVersion { get; set; }
    }

The columns have the same name as the attributes of this class.
I add my differents RowService in a BindingList called bSourceServices. When I try to associate it to my grid with the following line, the grid stay empty :

plkUcGridView1.DataSource = bSourceServices;
Here is a picture of what I obtain
My grid is empty, even if bSourceServices isn't (I checked with a foreach and it contains what it should contains, the list isn't empty).

Thanks to anyone who would help me understand this problem !


Solution

  • Found the way to achieve what i wanted to do :
    i just needed to complete the empty field "FieldName" with the name of the attribute of my object.

    Now, it works great with myGridView.DataSource = myListOfObjects.
    Thanks !