Could someone please help show me what I'm doing wrong in vb.net:
I am trying to incorporate a WebExcelExporter in my asp.net web site. I am able to get the my web site to compile, and I can get the webExcelExporter to open up a spreadsheet, but all I get in the spread sheet are my column headings. No Data is present.
Here is my configuration: I have two infragistics WebDataGrids, 'gvSales' and 'gvInventory'. Each grid is on a separate UpdatePanel. I copied the logic of the "Samples.infragistics.com" web site and came up with the following code for my button click event.
Dim fileName As String = HttpUtility.UrlEncode(tbFileName.Text) fileName = fileName.Replace("+", "%20") eExporter.DownloadName = fileName Me.eExporter.DataExportMode = DirectCast([Enum].Parse(GetType(DataExportMode), Me.rblExportData.SelectedValue), DataExportMode) Me.eExporter.WorkbookFormat = DirectCast([Enum].Parse(GetType(Infragistics.Excel.WorkbookFormat), Me.rblExcelFormat.SelectedValue), Infragistics.Excel.WorkbookFormat) Dim singleGridPerSheet As Boolean = If((Me.rblSheets.SelectedValue = "separate"), True, False) Me.eExporter.Export(singleGridPerSheet, gvSales, gvInventory)
Also: Could someone please explain what these two lines are actually doing.
Me.eExporter.DataExportMode = DirectCast([Enum].Parse(GetType(DataExportMode), Me.rblExportData.SelectedValue), DataExportMode) Me.eExporter.WorkbookFormat = DirectCast([Enum].Parse(GetType(Infragistics.Excel.WorkbookFormat), Me.rblExcelFormat.SelectedValue), Infragistics.Excel.WorkbookFormat)
Thanks
Dave.
Hello Dave,
Let me know if you need further assistance with this question.
“WebDataGrid” control has its own AJAX functionality and the “UpdatePanel” is not required for this control. If you want to use “WebDataGrid” in “UpdatePanel” you may consider setting “EnableAjax” property of the grid to “false” and set all Postback flags of the grid to “On”.
You can try to comment the “UpdatePanel” controls and export the grids again.
You can also put a breakpoint before “Export” method and observe the two grids passed to the method – if the data is not present in the two grids then you probably does not applying the Datasource to the grid in every Postback to the server.
The mentioned by you two lines of code are used to pass the “DataExportMode” and “WorkbookFormat” to the exporter. These values are taken from the radio buttons on the page and casted to the needed format in the code.
You can use:
Me.eExporter.WorkbookFormat = Infragistics.Excel.WorkbookFormat.<choose format>
if you have no radio buttons on the page.
Here is my html source if it helps.
<fieldset style="height: 650px"> <legend>Results:</legend> <ig:WebExcelExporter runat="server" ID="eExporter" ExportMode="Download"/> <div style="padding-top: 30px;"> <fieldset class="fieldset"> <legend class="icoExporter">Export Options</legend> <fieldset class="fldOptions"> <legend>Format</legend> <asp:RadioButtonList ID="rblExcelFormat" runat="server" AutoPostBack="false" ToolTip="WorkbookFormat - Determines the format of the exported excel file." Width="249px"> <asp:ListItem Text="Excel 97-2003 Format" Value="Excel97To2003" /> <asp:ListItem Text="Excel 2007 Format" Value="Excel2007" Selected="True" /> </asp:RadioButtonList> </fieldset> <fieldset class="fldOptions"> <legend>Export Mode</legend> <asp:RadioButtonList CssClass="props" ID="rblExportData" runat="server" AutoPostBack="false" ToolTip="DataExportMode - whether the grid will export the entire set of data." Width="217px"> <asp:ListItem Text="Export Visible Data" Value="DataInGridOnly" /> <asp:ListItem Text="Export All Data" Value="AllDataInDataSource" Selected="True" /> </asp:RadioButtonList> </fieldset> <fieldset class="fldOptions"> <legend>Sheets</legend> <asp:RadioButtonList ID="rblSheets" runat="server" AutoPostBack="false" Width="259px"> <asp:ListItem Text="Export in Single Sheet" Value="single" Selected="True" /> <asp:ListItem Text="Export in separate Sheets" Value="separate" /> </asp:RadioButtonList> </fieldset> <div style="display: block; clear: both;" /> <br /> <div> <asp:Label runat="server" ID="lblFileName" Text="Enter file name (w/o extension):" /> <asp:TextBox runat="server" ID="tbFileName" Text="ExportedData" Style="width: 612px;" /> <asp:Button runat="server" ID="btnExport1" Text="Export" CssClass="button" /> </div> </fieldset> </div> <center> <br /> <div id="GridView"> <asp:UpdatePanel ID="updgvSales" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="lbGrSales" runat="server" Text="Sales" Font-Size="Large"></asp:Label> <br> <ig:WebDataGrid ID="gvSales" runat="server" Height="250px" Width="80%" DefaultColumnWidth="200px" StyleSetName="Default"> <ClientEvents Initialize="Init_gvSales" /> <Behaviors> <ig:Paging PagerAppearance="Bottom" PageSize="200" QuickPages="3" Enabled="true" PagerMode="NumericFirstLast" /> <ig:Filtering> </ig:Filtering> <ig:Sorting> </ig:Sorting> <ig:ColumnResizing Enabled="true"> <ColumnSettings> <ig:ColumnResizeSetting EnableResize="true" /> </ColumnSettings> </ig:ColumnResizing> <ig:Selection> </ig:Selection> <ig:RowSelectors Enabled="true" RowNumbering="true" /> </Behaviors> <ErrorTemplate> An Error has occured while trying to display the current query! </ErrorTemplate> <EmptyRowsTemplate> No Data Available for current query </EmptyRowsTemplate> </ig:WebDataGrid> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnViewSales" EventName="Click" /> <asp:AsyncPostBackTrigger ControlID="btnViewAll" EventName="Click" /> </Triggers> </asp:UpdatePanel> <br /> <asp:UpdatePanel ID="updgvInv" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="lbGrInv" runat="server" Text="Inventory" Font-Size="Large"></asp:Label> <br /> <ig:WebDataGrid ID="gvInventory" runat="server" Height="250px" Width="80%" DefaultColumnWidth="200px" StyleSetName="Default"> <ClientEvents Initialize="Init_gvInventory" /> <Behaviors> <ig:Paging PagerAppearance="Bottom" PageSize="200" QuickPages="3" Enabled="true" PagerMode="NumericFirstLast" /> <ig:Filtering> </ig:Filtering> <ig:Sorting> </ig:Sorting> <ig:ColumnResizing Enabled="true"> <ColumnSettings> <ig:ColumnResizeSetting EnableResize="true" /> </ColumnSettings> </ig:ColumnResizing> <ig:Selection> </ig:Selection> <ig:RowSelectors Enabled="true" RowNumbering="true" /> </Behaviors> <ErrorTemplate> An Error has occured while trying to display the current query! </ErrorTemplate> <EmptyRowsTemplate> No Data Available for current query </EmptyRowsTemplate> </ig:WebDataGrid> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnViewInv" EventName="Click" /> <asp:AsyncPostBackTrigger ControlID="btnViewAll" EventName="Click" /> </Triggers> </asp:UpdatePanel> <br /> <asp:UpdatePanel ID="updStatus" runat="server" UpdateMode="Conditional"> <ContentTemplate> <div id="imgStatus" style="position: absolute; left: 20px;"> <table cellspacing="3"> <tr> <td> <asp:Image ID="imgResult" runat="server" ImageUrl="Styles/Images/Success.png" Height="16px" Width="16px" /> </td> <td> <asp:Label ID="lblImgText" runat="server" Text="" Style="font-size: 7pt;"></asp:Label> </td> </tr> </table> </div> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnViewInv" EventName="Click" /> <asp:AsyncPostBackTrigger ControlID="btnViewAll" EventName="Click" /> <asp:AsyncPostBackTrigger ControlID="btnViewSales" EventName="Click" /> </Triggers> </asp:UpdatePanel> </div> </center> </fieldset>