HOW TO BIND LIST<T> DATA IN DEVEXPRESS XTRAGRID CONTROL?

Carl Pieterson

Total Post:14

Points:98
Posted by  Carl Pieterson
C# 
C#
 23096  View(s)
Ratings:
Rate this:

Hello,

I want to bind data in devexpress grid control through generic list.
Can anyone explain me how can I acheive this task?

Thanks.

  1. Chris Anderson

    Post:65

    Points:455
    Re: How to bind List<T> data in devexpress XtraGrid control?

    hi,

    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.



      Modified On Jun-14-2012 03:57:58 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!