Hi Mike123,
After checking a lot, I find that:
1. launching page, click export to excel, it OK; but,
2. If I click the 'Select' button on row first, the problem (an error pop up message), then click the 'Select' button again, it is OK. After that, when click the 'Export' to Excel, I meet the problem; Or, after I use the filter data by search panel, the function of Exporting to Excel cannot be used any more because of the error message.
Here is my source code.
<data:GridViewSearchPanel ID="gvspOrder" runat="server" GridViewControlID="egvOrder" Visible="true"
OnSearchButtonClicked="gvspOrder_SearchButtonClicked" >
<FieldsToExclude>
<data:Field Value="O_ID" />
<data:Field Value="FundingSourceID" />
<data:Field Value="IsLockedMoney" />
<data:Field Value="XID" />
<data:Field Value="AuthCode" />
</FieldsToExclude>
</data:GridViewSearchPanel>
<br />
<data:EntityGridView ID="egvOrder" runat="server"
AutoGenerateColumns="False"
AutoGenerateSelectButton="True"
OnSelectedIndexChanged="egvOrder_SelectedIndexChanged"
DataSourceID="OrderDataSource" DataKeyNames="OId"
AllowMultiColumnSorting="False"
DefaultSortColumnName="Date" DefaultSortDirection="Ascending"
ExcelExportFileName="Export_Order.xls" OnExcelBeforeFormat="egvOrder_ExcelBeforeFormat"
AllowExportToExcel="False" ExportToExcelText="Excel" ExportToolTip="Click here to export Excel"
AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="Both"
PageSelectorPageSizeInterval="10"
SortAscImageUrl="Images/sortascending.gif" SortDescImageUrl="Images/sortdescending.gif"
>
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<Columns>
<asp:CommandField ShowSelectButton="True" ShowEditButton="True" Visible="False"/>
<asp:BoundField DataField="Code" HeaderText="Customer Code" SortExpression="Code" />
<asp:BoundField DataField="OrderAction" HeaderText="Action" SortExpression="OrderAction" />
<asp:BoundField DataField="Symbol" HeaderText="Symbol" SortExpression="Symbol" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
<asp:BoundField DataField="MatchedQuantity" HeaderText="Matched Quantity" SortExpression="MatchedQuantity" />
<asp:BoundField DataField="OrderType" HeaderText="Matched Quantity" SortExpression="OrderType" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="Fee" HeaderText="Fee" SortExpression="Fee" />
<asp:BoundField DataField="MatchedAmount" HeaderText="Matched Amount" SortExpression="MatchedAmount" />
<asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
<asp:BoundField DataField="OrderStatus" HeaderText="Status" SortExpression="OrderStatus" />
<asp:BoundField DataField="FundingSourceId" HeaderText="Funding Source ID" SortExpression="FundingSourceID" Visible="False" />
<asp:BoundField DataField="FundingSourceName" HeaderText="Funding Source Name" SortExpression="FundingSourceName" />
<asp:BoundField DataField="XId" HeaderText="XID" SortExpression="XID" Visible="False" />
<asp:TemplateField HeaderText="Matched Details">
<ItemTemplate>
<asp:GridView ID="egvMatch" runat="server" AllowMultiColumnSorting="false" OnSorting="egvMatch_Sorting"
AutoGenerateColumns="False" DataKeyNames="MId" DataSource='<%#GetTrasnl(Convert.ToInt32(Eval("OId"))) %>'
ExcelExportFileName="Export_OrderMatch.xls" BackColor="White"
BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1"
GridLines="None">
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="White" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle Height="18pt" BackColor="#DEDFDE" ForeColor="Black" />
<Columns>
<asp:BoundField DataField="MatchId" HeaderText="Match Id" SortExpression="MatchID" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
<asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="Amount" />
<asp:BoundField DataField="Time" DataFormatString="{0:g}" HeaderText="Time" HtmlEncode="False"
SortExpression="Time" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" Visible="False"/>
</Columns>
<EmptyDataTemplate>
<b>No Matching Found!</b>
</EmptyDataTemplate>
</asp:GridView>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<b>No Order Found!</b>
</EmptyDataTemplate>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
</data:EntityGridView>
<br />
<br />
<br />
<asp:Label ID="lblMessage" runat="server"></asp:Label><br />
<data:VOrderViewDataSource ID="OrderDataSource" runat="server"
SelectMethod="GetPaged"
EnablePaging="True"
EnableSorting="True"
>
<Parameters>
<data:CustomParameter Name="WhereClause" Value="" ConvertEmptyStringToNull="false" />
<data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" />
<asp:ControlParameter Name="PageIndex" ControlID="egvOrder" PropertyName="PageIndex" Type="Int32" />
<asp:ControlParameter Name="PageSize" ControlID="egvOrder" PropertyName="PageSize" Type="Int32" />
<data:CustomParameter Name="RecordCount" Value="0" Type="Int32" />
</Parameters>
</data:VOrderViewDataSource>