I have been find a solution but until now I dint solve the problem. I'm going to explain about it.
There is a .aspx page where there is a radgrid. There are also two buttons - word button and excel button.
When the user clicks on word button for example it is invoked its event:
protected
void btnExportWord_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
RadGrid radGrid = this.getData();
this.ConfigureExportation(radGrid);
radGrid.MasterTableView.ExportToWord();
}
How you can see, I create a new radgrid where it is filled out by getData method. I created a new radgrid because on page, the radgrid has jus some columns and I'd like to export all columns from table to word or excel file.
See the getData() Method:
private
RadGrid getData()
{
RadGrid radGrid = new RadGrid();
radGrid.DataSource = gobjBLProduct.List(
this.Company, this.txtSearch.Text.Trim());
radGrid.DataBind();
return radGrid;
}
Now, See ConfigureExportatio() Method:
private
void ConfigureExportation(RadGrid pradGrid)
{
pradGrid.ExportSettings.ExportOnlyData =
true;
pradGrid.ExportSettings.IgnorePaging =
true;
pradGrid.ExportSettings.OpenInNewWindow =
true;
pradGrid.ExportSettings.FileName =
"List of Product - " + DateTime.Now.ToShortDateString();
}
The problem is when I click on word button there is an exception where it is showed this message: "RadGrid must be DataBound" before exporting."
I didnt undertand why this error. What mistake did i do?
Can anybody help me, please?
Thank you for attention,
Carlos