Using EntityCollection directly with Grid.

Posts   
 
    
Posts: 12
Joined: 05-Apr-2006
# Posted on: 24-May-2006 15:09:07   

Hi Everyone,

I am trying to display columns from different tables to a grid. I have the results in an entity collection.

Code :

EntityCollection AllCollection = GetData(); this.resultGrid.DataSource = AllCollection;

Table1 Rollno Name Mark1 Mark2 Mark3

Table2 Rollno Address1 Address2

So, the entity collection now holds all these columns. But i need to display only the Rollno and Address1 columns.

I tried using the Data Table. Creating new columns and fetching the necessary columns. It works well.

But i need to know whether there is a way to format the Entity Collection, to display the necessary columns alone?

Thanks in Advance, Dhivya

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 24-May-2006 15:15:04   

You should use a datagridTableStyle and select the columns that you want to display from the GridColumnStyles .

Posts: 12
Joined: 05-Apr-2006
# Posted on: 26-May-2006 15:49:35   

Hi Walaa,

Thanks for ur fast response.

Could you please explain me in more detail what should be done?

I want the EntityCollection to be used directly with the grid without any DataTable in the intermediate.

Now my EntityCollection holds several columns, but i need to display only certain columns from it.

Thanks in Advance, Dhivya

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 27-May-2006 03:55:59   

If you only want to display certain columns in your grid then do not auto generate you columns in your grid. Define the columns and fields that they map to manually in the designer.