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

[Solved] RadGridView displaying empty data..

1 Answer 168 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sachin jagtap
Top achievements
Rank 1
sachin jagtap asked on 30 Jul 2009, 02:28 PM
Hi i am trying to display contents of List<> data to a grid, but instead the grid is displaying empty rows.
following is the code. i can see the data in List , but Grid is not displaying anything.
Code for reference...

public

 

class Assignees

 

{

 

public int responsible_key;

 

 

public string responsible_name;

 

 

public string department;

 

 

public string emailid;

 

 

}

 

public

 

void Load(string xml)

 

{

 

XDocument doc = XDocument.Parse(xml);

 

 

 

var data = from xelem in doc.Descendants("AssigneeDTO")

 

 


select
new Assignees

 

{

department = xelem.Element(

"department").Value,

 

emailid = xelem.Element(

"emailid").Value,

 

responsible_key =

Convert.ToInt32(xelem.Element("responsible_key").Value),

 

responsible_name = xelem.Element(

XName.Get("responsible_name").Value

 

};

 

Assignee_Grid.ItemsSource = data;

 

}

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan Dobrev
Telerik team
answered on 04 Aug 2009, 10:40 AM
Hi sachin jagtap,

RadGridView did not support auto generation of columns based on public fields. Following the best practices we are relying on public properties to auto generate grid's columns, so that we can provide support for bindings and property change notifications.

Currently you can make one of the following thing to make it work:
  • Define you public fields as properties. I'm recommending this approach:
public class Assignees 
    public string department{ getset;} 
    public string emailid { getset; } 
    public int responsible_key { getset; } 
    public string responsible_name { getset; } 
  • Set AutoGenerateColumns property of RadGridView to false and define new GridViewDataColumn for each of the column you have to display.

Regards,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
sachin jagtap
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
Share this question
or