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

exporting radgrid fails

2 Answers 81 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gila
Top achievements
Rank 1
gila asked on 06 Jun 2011, 07:28 AM
Hello,
I have a solution contains radgrid in witch there are also template columns.
Calling the ExportToExcel method from a button event of export falls with the error:
"Object refernce" in pre-render of grid event, because of hiding the checkbox column.
And even if i skip the per-render code by flag, the export doesnt work.
Actually the export doesnt work and my grid on screen has no checkbox anymore but "false" in the column.
I have tried hiding the column, but nothing helps.
I have spent many hours reading same problems but none of the solutions helped me.
I also tried putting standard code of exporting, like gridview (with response and htmltextwriter) but it falls with error:

יש למקם את הפקד '

ctl00_contentBody_gridInviteds_ctl00_ctl02_ctl00_ctl00' מסוג 'GridLinkButton' בתוך תג טופס עם runat=server.

 


Actually, when my grid is with no template columns, the export is working but still there is a poblem that the headers have a button in the excel sheet, even though i wrote in code "allowSorting=false"

thanks,
gila
  

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jun 2011, 08:36 AM
Hello Gila,

I am not quite sure about your requirement. If you want to hide that particular template column in a button click, try the following code snippet.

C#:
protected void Button1_Click(object sender, EventArgs e)
    {
    RadGrid1.MasterTableView.GetColumn("ColumnUniqueName").Visible = false;
       RadGrid1.MasterTableView.ExportToExcel();
    }

Check the following help documentation which explains more about this.

ExcelML basics.

Thanks,
Princy.
0
gila
Top achievements
Rank 1
answered on 06 Jun 2011, 12:11 PM
thanks, but the code you have givven me already i did, when i said i tried to hide the column.
I have found that my problem has a connection to ajax I set in my page.
My solution  now is to put another grid on page, with visible=false, and when clicking on the export button, set the datasource of the exported grid to be the list of the orgional grid, call databind and then call exportToExcel.
the advantage is that i dont need to do nothing with template clumns or change something with my ajax, because this grid is out of what the user see on screen.
also it won't make problems with the buttons on header.
Till now it works.

Thanks,
gila
Tags
Grid
Asked by
gila
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
gila
Top achievements
Rank 1
Share this question
or