Hi, In my application a radgrid contains a checkbox, a listbox and a dropdown control in itemtemplate.
I have used exporttoexcel feature of radgrid.
In exported data i don't want to export checkbox column value.
I want to export datatext field of listbox and dropdown list control instead of datavalue field being exported.
How can i resolve above issues?
I have used exporttoexcel feature of radgrid.
In exported data i don't want to export checkbox column value.
I want to export datatext field of listbox and dropdown list control instead of datavalue field being exported.
How can i resolve above issues?
4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 19 Jul 2011, 10:43 AM
Hello Anil,
Try the following code snippet in ExportCellFormatting event to hide CheckBox in ItemTemplate when exporting to excel.
C#:
Thanks,
Shinu.
Try the following code snippet in ExportCellFormatting event to hide CheckBox in ItemTemplate when exporting to excel.
C#:
protected void RadGrid1_ExportCellFormatting(object sender, ExportCellFormattingEventArgs e){ GridDataItem item = e.Cell.Parent as GridDataItem; if (e.FormattedColumn.UniqueName == "TemplateColumnUniqueName") { TableCell cell = item["TemplateColumnUniqueName"]; cell.Visible = false; }}Thanks,
Shinu.
0
Anil
Top achievements
Rank 1
answered on 19 Jul 2011, 12:46 PM
Hi Shinu,
After applying your code no data is exported. Instead a blank sheet with column names is exported. Also one blank column is for checkbox.
Also what can i do to export selected list box item and dropdown item?
After applying your code no data is exported. Instead a blank sheet with column names is exported. Also one blank column is for checkbox.
Also what can i do to export selected list box item and dropdown item?
0
Shinu
Top achievements
Rank 2
answered on 20 Jul 2011, 07:22 AM
Hello Anil,
You can try the following approach in ItemCommand event by setting the TemplateColumn visibility to false in which the checkbox lies.
aspx:
C#:
Thanks,
Shinu.
You can try the following approach in ItemCommand event by setting the TemplateColumn visibility to false in which the checkbox lies.
aspx:
<telerik:GridTemplateColumn UniqueName="TemplateColumn1" HeaderText="TemplateCol"> <ItemTemplate> <asp:Checkbox ID="Checkbox1" runat="server" Text="Hai"></asp:TextBox> </ItemTemplate></telerik:GridTemplateColumn><telerik:GridTemplateColumn UniqueName="TemplateColumn2" HeaderText="TemplateCol"> <ItemTemplate> <asp:ListBox ID="ListBox1" runat="server" DataTextField="LastName"> </asp:ListBox> <asp:DropDownList ID="DropDownList1" runat="server" DataTextField="City"> </asp:DropDownList> </ItemTemplate></telerik:GridTemplateColumn>protected void RadGrid1_ItemCommand1(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == RadGrid.ExportToExcelCommandName) { RadGrid1.MasterTableView.GetColumn("TemplateColumn1").Visible = false; } }Thanks,
Shinu.
0
Anil
Top achievements
Rank 1
answered on 21 Jul 2011, 08:09 AM
Thank you very much Shinu. With your solution i am able to resolve one of my reported problem(Do not export checkbox column).
Currently selected value of dropdown and listbox is exported. I want to export their text field.
what can i do to export selected list box item and dropdown item?
Currently selected value of dropdown and listbox is exported. I want to export their text field.
what can i do to export selected list box item and dropdown item?