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

[Solved] Newbie Question

1 Answer 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kaushik Subramanya
Top achievements
Rank 1
Kaushik Subramanya asked on 25 Aug 2009, 09:27 PM
Hi -

 I'm doing a trial of the the Telerik grid and want to know how to do the display data on the Grid;
 
I need to databind the grid (on the server side) to a IList<T> where T is a custom class. The grid does not display the data.

My Code is below

RadGrid.DataSource = <list>;

RadGrid.DataBind();


MS GridView displays the data from the same datasource.

Please advise  

Thanks
Kaushik

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2009, 05:18 AM
Hi Kaushik,

I tried the scenario in my end (by using IList object collection to bind grid) and it is working fine. Here is the code that I tried.

C#:
 
protected void Page_Load(object sender, EventArgs e) 
    BindData(); 
private void BindData() 
    IList<UserInfo> userinfos = new List<UserInfo>(); 
    int i = 0; 
    for (i = 0; i <= 4; i++) 
    { 
        UserInfo info = new UserInfo("username" + i.ToString(), "password" + i.ToString()); 
        userinfos.Add(info); 
    } 
 
    //this.GridView1.DataSource = userinfos; 
    //this.GridView1.DataBind(); 
 
    this.RadGrid2.DataSource = userinfos; 
    this.RadGrid2.DataBind(); 
public class UserInfo 
    private string _userName = string.Empty; 
    private string _password = string.Empty; 
 
    public UserInfo() 
    { 
 
    } 
    public UserInfo(string userName, string password) 
    { 
        this._userName = userName; 
        this._password = password; 
    } 
 
    public string UserName 
    { 
        get { return _userName; } 
    } 
 
    public string Password 
    { 
        get { return _password; } 
    } 
Can you try the above code and see whether it is working fine for you? Hope this help you to find out the issue.

-Shinu.
Tags
Grid
Asked by
Kaushik Subramanya
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or