RadGridView DataSource

3 posts, 0 answers
  1. 勇誌
    勇誌 avatar
    8 posts
    Member since:
    Mar 2018

    Posted 27 Mar 2018 Link to this post

    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. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4129 posts

    Posted 28 Mar 2018 Link to this post


    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. 

    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.
  3. 勇誌
    勇誌 avatar
    8 posts
    Member since:
    Mar 2018

    Posted 28 Mar 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Doss ! Thanks for your help ! it really helps me a lot !
    i'm so happy that you can answer my question :'(
    Honestly , thank you !
Back to Top