Contact Sales: +1-888-365-2779
Community & Support
Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > Export to CSV returns empty file

Not answered Export to CSV returns empty file

Feed from this thread
  • Rizwan avatar

    Posted on Jun 17, 2009 (permalink)

    Hi
      I am building a web application which contains list of grids in different area's. All have export options working fine but there is one grid which Export blank CSV even there is record. I have tried every possible option  but no output. Any help would be appreciated. this is the HTML code.

     

    <telerik:RadGrid ID="radGridSelectUser" runat="server" Skin="Office2007"

     

     

    AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"

     

     

    AllowMultiRowSelection="true" Width="99%" >

     

     

    <GroupingSettings CaseSensitive="false" />

     

     

    <ExportSettings OpenInNewWindow="true">

     

     

    <Pdf FontType="Link" PaperSize="A4" />

     

     

    <Excel Format="Html" />

     

     

    <Csv ColumnDelimiter="Comma" RowDelimiter="NewLine" />

     

     

    </ExportSettings>

     

     

    <ClientSettings>

     

     

    <Selecting AllowRowSelect="true" />

     

     

    </ClientSettings>

     

     

     

    <MasterTableView >

     

     

    <PagerTemplate>

     

     

    <!-- This is my custom footer-->

     

     

     

     

     

    <uc1:gridFooter ID="gridFooter" runat="server" />

     

     

    </PagerTemplate>

     

     

    <Columns>

     

     

    <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" DataField="Username" SortExpression="Username" FilterControlWidth="95%" >

     

     

    <ItemTemplate>

     

     

    <asp:LinkButton runat="server" ID="lnkUserName" OnClick="lnkUserName_Click" ToolTip='<%# DataBinder.Eval(Container.DataItem,"Username")%>' CommandName="SELECT" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"UserId")%>' Text='<%# DataBinder.Eval(Container.DataItem,"Username")%>'></asp:LinkButton>

     

     

    </ItemTemplate>

     

     

    </telerik:GridTemplateColumn>

     

     

    </Columns>

     

     

    </MasterTableView>

     

     

     

    </telerik:RadGrid>

     



    Code Behind on Button Click

    // There are mostly records between 2- 10

    radGridSelectUser.ExportSettings.ExportOnlyData =

    true;

     

    radGridSelectUser.ExportSettings.IgnorePaging =

    true;

     

    radGridSelectUser.ExportSettings.OpenInNewWindow =

    true;

     

    radGridSelectUser.MasterTableView.ExportToCSV();


    Best Regards

     

    Rizwan Bashir

     

    Reply

  • Pavlina Pavlina admin's avatar

    Posted on Jun 17, 2009 (permalink)

    Hi Rizwan,

    I suggest you using the tips from this section of the documentation (paragraph 'Exporting GridButtonColumn/GridTemplateColumn/GridHyperLinkColumn data') to export the template column.

    All the best,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Rizwan avatar

    Posted on Jun 17, 2009 (permalink)

    Hi
       Thanks for the link, I have added another column in the grid

    <

     

    telerik:GridBoundColumn DataField="Username" HeaderText="Username" AllowSorting="true" Display="true" ></telerik:GridBoundColumn>

     



    this is GroupBound column which must be exported but even then I get CSV with headers only.i-e Username , Username   and thats  it.
    so if it does not find the data for first column then it must display the second one but nothing here.

    Any other options ?

    Best Regards
    RIzwan Bashir

    Reply

  • Pavlina Pavlina admin's avatar

    Posted on Jun 17, 2009 (permalink)

    Hi Rizwan,

    I followed your scenario in order to replicate the issue but to no avail. Please find attached a simple runnable application which is working as expected. Give it a try and let me know what is the difference in your case.

    Looking forward for your reply.

    All the best,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
    Attached files

    Reply

  • Rizwan avatar

    Posted on Jun 18, 2009 (permalink)

    hi
      I am unable to replicate my problem on your sample page neither able to fix it on my application but there are 2 issues which arise on this page and may be useful for you as I am not facing these problems on my main application.
    You can download the source from
    http://www.alm-soft.com/Rizwan/135059_export-to-csv.zip

    I have removed the telerik files from bin which you can put back before playing with it.

    problems on newly added grid
    1)  If you click next on navigation then it will not work but if you will click on page "2" then it will.
    2) if you export the grid to CSV  then file name should be "Username.csv" but it would be something like Username324234.csv

    these problems do not appear in my orignal application but appear here so I thought to brought them in your attention.

    Best Regards
    Rizwan Bashir

    Reply

  • Pavlina Pavlina admin's avatar

    Posted on Jun 18, 2009 (permalink)

    Hello Rizwan,

    Could you please verify that this is the correct link, because I was not able to open it?
    It will be best if you can open a formal support ticket and send us a simple running project  demonstrating the problem (and step-by-step instructions on doing so). In that way we can reproduce and pinpoint the problems you're facing on our side, understand the logic of your application and provide a solution.

    Best wishes,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Rizwan avatar

    Posted on Jun 18, 2009 (permalink)

    hi
       The link is still alive but it is case sensitive so please copy paste this
    http://www.alm-soft.com/Rizwan/135059_export-to-csv.zip

    in browser and it should work. As far the issue is concerned, I am facing this only on grid in my entire application so reproducing it is not a piece of cake :-) even I am not able to recreate it on other controls. May be rebuilding the contrl from scratch would resolve the problem.
      I shall try it again on another application and if I manage to reproduce it then I shall get the ticket and will update here as well.

    Best Regards
    Rizwan Bashir

    Reply

  • Maulik avatar

    Posted on Jun 18, 2009 (permalink)

    Hi,

    I have similar problem.

    When I export to Word, Excel or PDF it works fine.

    With CSV it generates file with only header information.

    I am trying to exprot grid which is not visible. If i make visible="true" it works fine.

    Is there a way to make it work with visible="false"

    Reply

  • Pavlina Pavlina admin's avatar

    Posted on Jun 22, 2009 (permalink)

    Hi Maulik,

    Please find attached a modified project that demonstrates the needed approach. Note that Simple data-binding through the DataBind() method can be used in simple scenarios which does not require complex operations like paging. For advanced features such as paging, RadGrid must be bound through the NeedDataSource event.

    Additionally, as you can see from the attached screenshot the name of the CSV file is "Username.csv".

    Best wishes,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.

    Reply

  • Q1 Webinar Week

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > Export to CSV returns empty file
Related resources for "Export to CSV returns empty file"

ASP.NET Grid Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]