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

Using Objects as Datasources

3 Answers 125 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alfred Ortega
Top achievements
Rank 2
Alfred Ortega asked on 28 May 2007, 05:50 PM
I've recently started using DevForce for middle-tier development on my winform applications and am having difficulty binding with the Telerik GridView.  I saw in the example the grid binds to arraylists but what about Generic Collections?  The grid binds to all properties and I don't see a way to control that.  Am I missing something?

Al

3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 29 May 2007, 03:21 PM
Hello Alfred Ortega,

To control this operation, you must set AutoGenerateColumns to false and add manually the needed columns. Here is a snippet for this scenario:
 
radGridView1.GridElement.BeginUpdate(); 
radGridView1.MasterGridViewTemplate.AutoGenerateColumns = false
 
GridViewDataColumn col = new GridViewDataColumn("Property1"); 
radGridView1.MasterGridViewTemplate.Columns.Add(col); 
 
col = new GridViewDataColumn("Property2"); 
radGridView1.MasterGridViewTemplate.Columns.Add(col); 
 
radGridView1.GridElement.EndUpdate(); 
radGridView1.DataSource = genericColl

I hope this helps.

Regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
lchesnais
Top achievements
Rank 1
answered on 12 Jun 2008, 02:03 PM
@Telerik,

Do you plan to add AutoGenerateColumns in the designer or the Property Window?
Honnestly it is not very convenient not to find it at least in the Property Window.

Maybe I'm stupid but I lost 30 minutes trying to find this property (which BTW is displayed in the Property Window in RadControls ASP.NET AJAX)

BR, Laurent
0
Julian Benkov
Telerik team
answered on 13 Jun 2008, 09:16 AM
Hi Laurent,

The AutoGenerateColumns property of the GridViewTemplate is not visible at design time. By default, at design time the AutoGenarateColumns is true and can only change in run time. This behavior follows Microsoft DataGridView behavior.

At design time, once the DataSource is set, the RadGridView auto generates the columns. Once this happens, you can clear, change, delete and manually add your own columns with the desired settings and mapping to data.

If you need further information, please contact me.

Sincerely yours,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Alfred Ortega
Top achievements
Rank 2
Answers by
Julian Benkov
Telerik team
lchesnais
Top achievements
Rank 1
Share this question
or