myDDL.DataTextField = ds.Tables[0].Columns["DATA"].ToString(); myDDL.DataValueField = ds.Tables[0].Columns[0].ToString(); myDDL.DataSource = ds.Tables[0]; var myValue = String.Empty; var ddlValue = DataBinder.Eval(DataItem, "DATA"); Session["ddlValue"] = ddlValue; myValue = Session["ddlValue"].ToString(); if (DataItem != null) { if (myDDL.FindItemByValue(ddlValue.ToString()) == null) { myDDL.SelectedIndex = -1; } else { myDDL.SelectedValue = ddlValue.ToString(); } } else { myDDL.SelectedValue = myValue; }}
<telerik:RadGrid ID="rgContacts" runat="server" AutoGenerateColumns="False" OnNeedDataSource="rgContacts_NeedDataSource" Skin="Silk" ShowHeader="false" GridLines="None" BorderStyle="Groove" BorderWidth="1px" Width="250px" BorderColor="#555555" AlternatingItemStyle-BackColor="White" BackColor="#bbeaf3"> <MasterTableView DataKeyNames="contact_id" EditMode="PopUp"> <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add a New Contact"/> <EditFormSettings PopUpSettings-Modal="true" UserControlName="controls/Contacts/CustomerContact.ascx" EditFormType="WebUserControl" InsertCaption="Create New Contact" CaptionFormatString="Edit Contact" FormCaptionStyle-Font-Bold="true" FormCaptionStyle-Font-Size="X-Large" FormStyle-BackColor="#dedddc" />Hi,
My requirement is to export RadGrid data to excel when user clicks on button outside RadGrid.
The following are the customizations that are needed:
1) Save or Open dialogue box should show up for opening or saving excel file.
2) Add company logo to excel file at certain position. Like row1 column1 to row5 column5. Logo size (gif format) is
always going to be same. Currently we are doing it by accessing worksheet and adding it.
3) we should be able to specify from where data should start showing up like row7..
4) We are hiding some columns in the grid. When exported, these shouldn't be exported.
5) Some rows in the grid are disabled. User can't click them. They shouldn't be exported.
6) Add a title and format it.
7) Format print options like margin etc..
I appreciate your help. Please let me know if there are any links about how to take care of it.
Thanks,
Prathiba.
radGuage.Pointer.Value =
Convert.ToDecimal(7.5);
<
telerik:RadRadialGauge ID="radGuage" runat="server" Skin="WebBlue">
<Pointer Color="Green">
<Cap Color="Lime" />
</Pointer>
<Scale MajorUnit="1" Max="8" Min="1" MinorUnit=".5">
<Labels Color="Black" Position="Outside" Visible="False" />
<Ranges>
<telerik:GaugeRange Color="#ccffcc" From="1" To="2" />
<telerik:GaugeRange Color="#99ccff" From="2" To="3" />
<telerik:GaugeRange Color="#0067b4" From="3" To="4" />
<telerik:GaugeRange Color="#826eb1" From="4" To="5" />
<telerik:GaugeRange Color="#ffff99" From="5" To="6" />
<telerik:GaugeRange Color="#ff9900" From="6" To="7" />
<telerik:GaugeRange Color="#ff6666" From="7" To="8" />
</Ranges>
</Scale>
</telerik:RadRadialGauge>
<telerik:GridButtonColumn ConfirmText="¿Eliminar registro?" ConfirmDialogType="RadWindow" ConfirmTitle="Eliminar" ButtonType="ImageButton" CommandName="Delete" ConfirmDialogHeight="140px" ConfirmDialogWidth="250px" ItemStyle-HorizontalAlign="Center" /><table cellpadding="0" cellspacing="0" border="0" width="990"> <tr> <td class="legendcolor" style="width: 450; text-align: center"> Activity Codes </td> <td class="legendcolor" style="width: 450; text-align: center"> Pay Groups </td> </tr> <tr> <td valign="top" style="width: 450; text-align: center"> <telerik:RadFilter Width="450" runat="server" ID="RadFilter2" Visible="false" FilterContainerID="RadGridActivity" EnableEmbeddedSkins="true" ShowApplyButton="false" /> <telerik:RadGrid ID="RadGridActivity" runat="server" OnItemCommand="RadGridActivity_ItemCommand" OnItemDataBound="RadGridActivity_ItemDataBound" OnItemCreated="RadGridActivity_ItemCreated" OnUpdateCommand="RadGridActivity_UpdateCommand" AutoGenerateColumns="False" PageSize="15" AllowPaging="True" AllowSorting="True" OnExcelExportCellFormatting="RadGridActivity_ExcelExportCellFormatting" OnInsertCommand="RadGridActivity_InsertCommand" CellSpacing="0" DataSourceID="ldsActivityCodes" GridLines="None" AllowFilteringByColumn="true" OnCSVExportCellFormatting="RadGridActivity_CSVExportCellFormatting" OnDeleteCommand="RadGridActivity_DeleteCommand"> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> <MasterTableView DataKeyNames="ID" DataSourceID="ldsActivityCodes" TableLayout="Fixed" IsFilterItemExpanded="false" CommandItemDisplay="Top" OverrideDataSourceControlSorting="true"> <CommandItemTemplate> <telerik:RadToolBar runat="server" ID="RadToolBar2" Height="24px" EnableEmbeddedSkins="true" OnButtonClick="RadToolBar2_ButtonClick" EnableRoundedCorners="true"> <Items> <telerik:RadToolBarButton Text="Show filter" CommandName="OpenRadFilter" /> <telerik:RadToolBarButton Text="Apply filter" CommandName="FilterRadGrid" /> <telerik:RadToolBarButton Text="Clear Filter" CommandName="ClearFilter" /> <telerik:RadToolBarButton Text="Hide filter" CommandName="CloseRadFilter" /> <telerik:RadToolBarButton Width="40px" Text="" CommandName="" /> <telerik:RadToolBarButton Text="" CommandName=""> <ItemTemplate> <telerik:RadButton ID="ExcelExportButton2" runat="server" Image-EnableImageButton="true" Image-ImageUrl="images/Export2Excel.gif" ToolTip="Export to Excel this page. Click Yes at MS 'different format' error message." Width="44px" Height="22px" CommandName="ExportToExcel" /> <telerik:RadButton ID="RadButton2" runat="server" Width="1px" Height="1px" /> <telerik:RadButton ID="CSVExportButton2" runat="server" Image-EnableImageButton="true" Image-ImageUrl="images/Export2CSV.gif" ToolTip="Export to CSV this page" Width="44px" Height="22px" CommandName="ExportToCSV" /> <telerik:RadButton ID="RadButton5" runat="server" Width="1px" Height="1px" /> <telerik:RadButton ID="AddButton" runat="server" Image-EnableImageButton="true" Image-ImageUrl="images/2Add.gif" ToolTip="Add New Employee" Width="44px" Height="22px" CommandName="InitInsert" /> </ItemTemplate> </telerik:RadToolBarButton> </Items> </telerik:RadToolBar> </CommandItemTemplate> <Columns> <telerik:GridBoundColumn DataField="FullName" FilterControlAltText="Filter FullName column" HeaderText="FullName" Visible="false" SortExpression="FullName" AllowFiltering="false" UniqueName="FullName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" FilterControlAltText="Filter ID column" HeaderText="ID" Visible="false" SortExpression="ID" AllowFiltering="false" UniqueName="ID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Code" DataType="System.Int32" FilterControlAltText="Filter Code column" HeaderText="Activity Code" ReadOnly="true" SortExpression="Code" UniqueName="Code"> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Top" Wrap="False" /> <ItemStyle HorizontalAlign="Center" Wrap="False" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Description" FilterControlAltText="Filter Description column" HeaderText="Description" ReadOnly="true" SortExpression="Description" UniqueName="Description"> <HeaderStyle HorizontalAlign="Center" Width="200" VerticalAlign="Top" Wrap="False" /> <ItemStyle HorizontalAlign="Center" Width="200" Wrap="False" /> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderText="Edit" ButtonType="ImageButton" /> <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" HeaderText="Delete" CommandName="Delete" ButtonType="ImageButton" /> </Columns> <EditFormSettings EditFormType="Template"> <FormTemplate> <table> <tr> <td class="gtempname"> Activity Code #: </td> <td align="left"> <telerik:RadNumericTextBox ID="txtActivityCode" runat="server" Width="30px" CssClass="gtextbox" Type="Number" NumberFormat-DecimalDigits="0" DbValue='<%# Bind("Code") %>' /> </td> </tr> <tr> <td class="gtempname"> Description: </td> <td align="left"> <asp:TextBox Width="150px" ID="txtACDescription" runat="server" CssClass="gtextbox" Text='<%# Bind("Description") %>'></asp:TextBox> </td> </tr> <tr> <td colspan="2"> <center> <asp:Button ID="btnUpdate" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'> </asp:Button> <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" CommandName="Cancel"></asp:Button></center> </td> </tr> </table> </FormTemplate> <EditColumn FilterControlAltText="Filter EditCommandColumn column"> </EditColumn> </EditFormSettings> </MasterTableView> <FilterMenu EnableImageSprites="False"> </FilterMenu> </telerik:RadGrid> </td> <td valign="top" style="width: 450; text-align: center"> <telerik:RadFilter Width="450" runat="server" ID="RadFilter3" Visible="false" FilterContainerID="RadGridPayGroups" EnableEmbeddedSkins="true" ShowApplyButton="false" /> <telerik:RadGrid ID="RadGridPayGroups" runat="server" OnExcelExportCellFormatting="RadGridPayGroups_ExcelExportCellFormatting" OnItemCreated="RadGridPayGroups_ItemCreated" OnDeleteCommand="RadGridPayGroups_DeleteCommand" AutoGenerateColumns="False" PageSize="15" AllowPaging="True" AllowSorting="True" OnItemCommand="RadGridPayGroups_ItemCommand" OnItemDataBound="RadGridPayGroups_ItemDataBound" OnUpdateCommand="RadGridPayGroups_UpdateCommand" CellSpacing="0" DataSourceID="ldsPayGroups" GridLines="None" AllowFilteringByColumn="true" OnCSVExportCellFormatting="RadGridPayGroups_CSVExportCellFormatting" OnInsertCommand="RadGridPayGroups_InsertCommand"> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> <MasterTableView DataKeyNames="ID" DataSourceID="ldsPayGroups" TableLayout="Fixed" IsFilterItemExpanded="false" CommandItemDisplay="Top" OverrideDataSourceControlSorting="true"> <CommandItemSettings ExportToPdfText="Export to PDF" /> <CommandItemTemplate> <telerik:RadToolBar runat="server" ID="RadToolBar3" Height="24px" EnableEmbeddedSkins="true" OnButtonClick="RadToolBar3_ButtonClick" EnableRoundedCorners="true"> <Items> <telerik:RadToolBarButton Text="Show filter" CommandName="OpenRadFilter" /> <telerik:RadToolBarButton Text="Apply filter" CommandName="FilterRadGrid" /> <telerik:RadToolBarButton Text="Clear Filter" CommandName="ClearFilter" /> <telerik:RadToolBarButton Text="Hide filter" CommandName="CloseRadFilter" /> <telerik:RadToolBarButton Width="40px" Text="" CommandName="" /> <telerik:RadToolBarButton Text="" CommandName=""> <ItemTemplate> <telerik:RadButton ID="ExcelExportButton3" runat="server" Image-EnableImageButton="true" Image-ImageUrl="images/Export2Excel.gif" ToolTip="Export to Excel this page. Click Yes at MS 'different format' error message." Width="44px" Height="22px" CommandName="ExportToExcel" /> <telerik:RadButton ID="RadButton3" runat="server" Width="1px" Height="1px" /> <telerik:RadButton ID="CSVExportButton3" runat="server" Image-EnableImageButton="true" Image-ImageUrl="images/Export2CSV.gif" ToolTip="Export to CSV this page" Width="44px" Height="22px" CommandName="ExportToCSV" /> <telerik:RadButton ID="RadButton4" runat="server" Width="1px" Height="1px" /> <telerik:RadButton ID="AddButton" runat="server" Image-EnableImageButton="true" Image-ImageUrl="images/2Add.gif" ToolTip="Add New Employee" Width="44px" Height="22px" CommandName="InitInsert" /> </ItemTemplate> </telerik:RadToolBarButton> </Items> </telerik:RadToolBar> </CommandItemTemplate> <Columns> <telerik:GridBoundColumn DataField="FullName" FilterControlAltText="Filter FullName column" FilterControlWidth="1" HeaderText="FullName" Visible="false" AllowFiltering="false" SortExpression="FullName" UniqueName="FullName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" FilterControlAltText="Filter ID column" FilterControlWidth="1" HeaderText="ID" Visible="false" AllowFiltering="false" SortExpression="ID" UniqueName="ID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="PayGroupCode" DataType="System.Int32" FilterControlAltText="Filter PayGroupCode column" HeaderText="PayGroupCode" ReadOnly="True" SortExpression="PayGroupCode" UniqueName="PayGroupCode" FilterControlWidth="100"> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Top" Wrap="False" /> <ItemStyle HorizontalAlign="Center" Wrap="False" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Description" FilterControlAltText="Filter Description column" FilterControlWidth="200" HeaderText="Description" ReadOnly="true" SortExpression="Description" UniqueName="Description"> <HeaderStyle HorizontalAlign="Center" Width="200" VerticalAlign="Top" Wrap="False" /> <ItemStyle HorizontalAlign="Center" Width="200" Wrap="False" /> </telerik:GridBoundColumn> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderText="Edit" ButtonType="ImageButton" FilterControlWidth="75" /> <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" HeaderText="Delete" CommandName="Delete" ButtonType="ImageButton" FilterControlWidth="75" /> </Columns> <EditFormSettings EditFormType="Template"> <FormTemplate> <table> <tr> <td class="gtempname"> PayGroupCode #: </td> <td align="left"> <telerik:RadNumericTextBox ID="txtPayGroupCode" runat="server" Width="30px" CssClass="gtextbox" Type="Number" NumberFormat-DecimalDigits="0" DbValue='<%# Bind("PayGroupCode") %>' /> </td> </tr> <tr> <td class="gtempname"> Description: </td> <td align="left"> <asp:TextBox Width="150px" ID="txtPGDescription" runat="server" CssClass="gtextbox" Text='<%# Bind("Description") %>'></asp:TextBox> </td> </tr> <tr> <td colspan="2"> <center> <asp:Button ID="btnUpdate" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'> </asp:Button> <asp:Button ID="btnCancel" runat="server" Text="Cancel" CausesValidation="false" CommandName="Cancel"></asp:Button></center> </td> </tr> </table> </FormTemplate> <EditColumn FilterControlAltText="Filter EditCommandColumn column"> </EditColumn> </EditFormSettings> </MasterTableView> <FilterMenu EnableImageSprites="False"> </FilterMenu> </telerik:RadGrid> </td> </tr> </table><br />