Hi guys,
I am a newbie to Telerik controls. I am trying to implement exporting functionality on the grid to export only selected rows to CSV format as follows:
On the server-side I have handled ItemCommand event as follows:
But when i click the export link after selecting a few rows, nothing happens. It shows me the loading panel. It also goes into the server-side code and executes ExportToCSV(). Also another strange thing happens - the grid reduces to the records I have selected i.e. the page initially is set to show 5 records, and I select only 2 of it to export, once the call comes back from the exportToCSV(), it shows me only the 2 records which were selected. Also, when moving to the next page and back, everything comes to normal.I can all my records again.
Any ideas on what I am doing wrong?
Regards,
I am a newbie to Telerik controls. I am trying to implement exporting functionality on the grid to export only selected rows to CSV format as follows:
| <CommandItemTemplate> |
| <table cellpadding="2" cellspacing="1" style="font-family: Tahoma; font-size: 11px" |
| width="100%"> |
| <tr> |
| <td style="text-align: left"> |
| <asp:LinkButton ID="hlInsertBank" runat="server" CommandName="InitInsert" Text="Insert"></asp:LinkButton> |
| </td> |
| <td style="text-align: right"> |
| <asp:LinkButton ID="exportBankDetails" runat="server" Text="Export" CommandName="ExportToCSV" ></asp:LinkButton> |
| </td> |
| </tr> |
| </table> |
On the server-side I have handled ItemCommand event as follows:
| protected void RadGrid_Bank_ItemCommand(object sender, GridCommandEventArgs e) |
| { |
| RadGrid grid = (RadGrid)sender; |
| int itemIndex = e.Item.ItemIndex; |
| if (e.CommandName == "ExportToCSV") |
| { |
| foreach (GridDataItem dataItem in grid.MasterTableView.Items) |
| { |
| dataItemdataItem.Display = dataItem.Selected; |
| } |
| grid.MasterTableView.ExportToCSV(); |
| } |
| } |
But when i click the export link after selecting a few rows, nothing happens. It shows me the loading panel. It also goes into the server-side code and executes ExportToCSV(). Also another strange thing happens - the grid reduces to the records I have selected i.e. the page initially is set to show 5 records, and I select only 2 of it to export, once the call comes back from the exportToCSV(), it shows me only the 2 records which were selected. Also, when moving to the next page and back, everything comes to normal.I can all my records again.
Any ideas on what I am doing wrong?
Regards,