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

RadGridView DataSource

2 Answers 1021 Views
GridView
This is a migrated thread and some comments may be shown as answers.
勇誌
Top achievements
Rank 1
勇誌 asked on 27 Mar 2018, 06:59 AM

Hi , I'm a new blood in programs. 

recently, I tried to build a RadGridView and fill in data from database

And I create a button if the user wanna export the data in RadGridView 

 

 RadGridView rgv = new RadGridView();

 rgv.DataSource = dt;

 GridViewSpreadExport spreadExporter = new GridViewSpreadExport(rgv);
            spreadExporter.ExportVisualSettings = true;
            SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
            spreadExporter.RunExport(filegoalpath, exportRenderer);

here is the method i used  , dt has data i wanna export .

so i used rgv to keep the data i wanna export and use these four program to export an excel 

but the program always tell me that my rgv is null and check it cant be null

after i checked , i found that rgv.DataSource really keeped my data in datatable

but rgv.Columns.Count is 0 and rgv.Rows.Count is 0 ,too.

 

actually this is my first time to write a program in C# 

but i really want to learn it well

so ... hope you can help me to solve my problem :(
plz !!!!

 

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Mar 2018, 12:22 PM
Hello,  

When you add a RadGridView programmatically at run time, note that it is necessary to initialize its BindingContext before setting the DataSource property. Thus, the grid will be successfully filled with data which can be exported later. I have prepared a sample project for your convenience.

I hope this information helps. 

Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
勇誌
Top achievements
Rank 1
answered on 29 Mar 2018, 01:12 AM
Doss ! Thanks for your help ! it really helps me a lot !
i'm so happy that you can answer my question :'(
Honestly , thank you !
Tags
GridView
Asked by
勇誌
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
勇誌
Top achievements
Rank 1
Share this question
or