I have a Radgrid that uses an objectdatasource which is configured this way
The Radgrid is declared in the designer of the page with this code:
I also added a button that will be used to export the datagrid once it is clicked. However, after generation of grid and clicking the export button the error: "RadGrid must be DataBound before exporting" is encountered. Here's the code behind for the page:
This is urgent, so please, any help will be appreciated.
thanks
<asp:ObjectDataSource runat="server" ID="reportObjectDataSource" SelectMethod="GetInfo" EnableViewState="false" TypeName="XXXX.ReportObjectDataSource" onselecting="reportObjectDataSource_Selecting"> <SelectParameters> <asp:FormParameter DbType="DateTimeOffset" DefaultValue="" FormField="timeFrom" Name="frDate" /> <asp:FormParameter DbType="DateTimeOffset" DefaultValue="" FormField="timeTo" Name="tDate" /> <asp:FormParameter DbType="Boolean" DefaultValue="" FormField="btnAllVer" Name="allVer" /> </SelectParameters> </asp:ObjectDataSource>The Radgrid is declared in the designer of the page with this code:
<telerik:RadGrid ID="gridReport" runat="server" GridLines="None" Skin="WebBlue" Width="700px" HeaderStyle-HorizontalAlign="Center" AllowSorting="True" AllowPaging="true" PageSize="50"> <MasterTableView AutoGenerateColumns="True"> <CommandItemSettings ShowExportToExcelButton="true"></CommandItemSettings> </MasterTableView> <ClientSettings> <Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" /> </ClientSettings> </telerik:RadGrid>I also added a button that will be used to export the datagrid once it is clicked. However, after generation of grid and clicking the export button the error: "RadGrid must be DataBound before exporting" is encountered. Here's the code behind for the page:
protected void btnGenerate_Click(object sender, EventArgs e) { gridReport.DataSourceID = "reportAdhocObjectDataSource"; } protected void btnExport_Click(object sender, EventArgs e) { gridReport.ExportSettings.FileName = "Report as of" + DateTime.Today.ToString(); gridReport.ExportSettings.ExportOnlyData = false; gridReport.ExportSettings.IgnorePaging = true; gridReport.ExportSettings.OpenInNewWindow = true; gridReport.MasterTableView.ExportToExcel(); } protected void reportObjectDataSource_Selecting(object sender, System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs e) { DateTime timeFr = timeFrom.SelectedDate.Value; DateTimeOffset tFrom = timeFr; e.InputParameters["frDate"] = tFrom; DateTime timeT = timeTo.SelectedDate.Value; DateTimeOffset tTo = timeT; e.InputParameters["tDate"] = tTo; e.InputParameters["allVer"] = this.btnAllVer.Checked; }This is urgent, so please, any help will be appreciated.
thanks