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

Need to use RadGrid in code, but not on form

2 Answers 51 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Mark asked on 07 Aug 2020, 04:14 PM

I need to use a RadGridView, so I can assign the DataSource.

 

However, when I do the following code, i get zero rows and columns.  What am I missing

 

 

List<Records> data = dbc.Records.ToList();
RadGridView gv = new  RadGridView();
gv.BeginUpdate();
gv.AutoGenerateColumns = true;
gv.AutoGenerateHierarchy = true;
gv.DataSource = data;
gv.EndUpdate();

 

 

When I look at the gridview, after the datasource is set, the row count and column count are zero?  Again, What I am doing wrong? The only thing that is different then what we are doing in our application, is the grid is not on a FORM.

 

Thanks

2 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
answered on 07 Aug 2020, 06:42 PM

Okay, after doing some more searching..i found that I have to initialize the BindingContext.  

 

 

 

0
Nadya | Tech Support Engineer
Telerik team
answered on 10 Aug 2020, 11:30 AM

Hi, Mark,

I am glad that you have already managed to found out why your grid remains empty after setting the DataSource. Initializing manually the BindingContext is required when you create and bind RadGridView programmatically in the code.

Please let me know if you have other questions.

Regards,
Nadya
Progress Telerik

Tags
GridView
Asked by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Answers by
Mark
Top achievements
Rank 2
Bronze
Iron
Veteran
Nadya | Tech Support Engineer
Telerik team
Share this question
or