Hello,
I want to bind data in devexpress grid control through generic list.
Can anyone explain me how can I acheive this task?
Thanks.
Hello,
I want to bind data in devexpress grid control through generic list.
Can anyone explain me how can I acheive this task?
Thanks.
you can achieve this task by using the code given below:
Fisrt step: Create a class and add some properties:
public class Sample
{
public string Name { get; set; }
public int Age { get;set; }
}
Second step: Add some sample data in the list
using System.Collections;
List<Sample> list =new List<Sample>();
list.Add( new Sample
{
Name="Rohit",
Age=20
});
list.Add( new Sample
{
Name="Rohit",
Age=20
});
Third Step: Bind list as datasource of gridcontrol.
gridControl1.DataSource = list;
Note:You also have to add the two fields in devexpress gridview and provide the FieldName of column as name of the property.