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

Bind a RadDataGrid to a single object

1 Answer 188 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Will
Top achievements
Rank 1
Will asked on 09 May 2013, 04:52 PM

I'm trying to bind a single row to a Telerik RadGridView in WinForms.  Since this list only ever contains one item, it seems inefficient to bind to a "List", even though I know that List only has one item. However, when I try to just bind to a single item in my list, nothing happens. Nothing shows up on my grid, but I don't get an error in the debugger.

This works. GetObjects is a Dal method that returns a List.

List<MyObject> myObjects = MyDal.GetObjects(myID); 
this.myGridView.DataSource = myObjects;

 

The following code does NOT work. GetObject is a Dal method that only returns the first element from a List.

MyObject myObject = MyDal.GetObject(myID); 
this.myGridView.DataSource = myObject;

I posted a similar question here .

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 14 May 2013, 11:57 AM
Hello Will,

Thank you for writing.

Please refer to the following article which explains what are the possibilities for binding RadGridView: http://www.telerik.com/help/winforms/gridview-populating-with-data-databinding-radgridview.html.

In your case, you will most likely have to add the object in an BindingList and bind the list to the grid.

I hope this helps.
 
Kind regards,
Stefan
the Telerik team
RadChart for WinForms is obsolete. Now what?
Tags
GridView
Asked by
Will
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or