or
Hello,
I have a problem in changing the RotatorScrollDirection using c# code
Here is the code, I'm using:
switch (scrollDirection) { case "Down": rotator1.ScrollDirection = RotatorScrollDirection.Down; break; case "Left": rotator1.ScrollDirection = RotatorScrollDirection.Left; break; case "Right": rotator1.ScrollDirection = RotatorScrollDirection.Right; break; case "Up": rotator1.ScrollDirection = RotatorScrollDirection.Up; break; }Is there any way to convert the string to object in order to prevent using the "switch" or "if" statements? for example, convert the string "Right" to the object "RotatorScrollDirection.Right"
Please, I need your help,
It is appreciated to send me the modified code.
Regards,
Bader
namespace iConnect.InvoicesScaling.Views { public partial class InvoicesScalingDefault : Microsoft.Practices.CompositeWeb.Web.UI.Page, IInvoicesScale { private InvoicesScalePresenter _presenter; public System.Collections.Generic.IList<Data.SapDocuments> SapDocuments { get; set; } protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { this._presenter.OnViewInitialized(); LoadData(); RadGrid1.DataBind(); } this._presenter.OnViewLoaded(); //A cada acesso à pagina verifica quem é o user //criar instancia da Info para aceder ao metodo que me vai buscar a lista de users ao AD Info x = new Info("xxx", "xxx", "xxxxx,DC=xx,DC=xx"); //get da lista dos direct report em user,key=manager(xx) Dictionary<string, string> networkUser = new Dictionary<string, string>(); networkUser = x.GetHierarchyTree("axxva3"); //MessageBox.Show(Page.User.Identity.Name); ////Popular dados na Radlist //RadGrid1.DataSource = this.SapDocuments; //RadGrid1.DataBind(); } [CreateNew] public InvoicesScalePresenter Presenter { set { this._presenter = value; this._presenter.View = this; } } private void LoadData() { ////Popular dados na Radlist RadGrid1.DataSource = this.SapDocuments; } protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e) { RadGrid1.CurrentPageIndex = e.NewPageIndex; LoadData(); RadGrid1.DataBind(); } protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName) { RadGrid1.MasterTableView.Columns.FindByUniqueName("SequencialNumber").Visible = false; // hide column before export RadGrid1.ExportSettings.IgnorePaging = true; RadGrid1.DataSource = this.SapDocuments; // please set data source again. RadGrid1.DataBind(); } } protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e) { LoadData(); } } } and my aspx file is: <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> <asp:Content ID="content" ContentPlaceHolderID="DefaultContent" runat="Server"> <script src="../Shared/js/jquery-1.6.2.min.js" type="text/javascript"></script> <script src="../Shared/js/jquery.tooltip.js" type="text/javascript"></script> <script type="text/javascript" src="../Silverlight.js"></script> <style type="text/css"> .RadGrid_Black .rgFilterBox { background-color: #454545 !important; } </style> <h1 style="text-align: center;"> Invoices Scale</h1> <br /> <div> <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowPaging="True" ViewStateMode= "Enabled" AllowSorting="True" AutoGenerateColumns="False" Width="97%" enableajax="True" CssClass="productsGrid" CellSpacing="0" AllowFilteringByColumn="True" ShowFooter="True" Skin="Black" AllowMultiRowSelection="True" onitemcommand="RadGrid1_ItemCommand" onpageindexchanged="RadGrid1_PageIndexChanged" onneeddatasource="RadGrid1_NeedDataSource" > <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True"> <Selecting AllowRowSelect="True" /> </ClientSettings> <MasterTableView GridLines="None" ViewStateMode="Enabled" Width="100%" EnableColumnsViewState="true" CommandItemSettings-ShowExportToCsvButton="True" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemDisplay="Top" > <Columns> <telerik:GridBoundColumn DataField="SequencialNumber" HeaderText="SequencialNumber" UniqueName="SequencialNumber" SortExpression="SequencialNumber"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Priority" HeaderText="Priority" UniqueName="Priority" FilterControlAltText="Filter Priority column" SortExpression="Priority" DataType="System.Int32"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Process" HeaderText="Staging" UniqueName="Process" SortExpression="Process" FilterControlAltText="Filter Process column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="SupplierCode" HeaderText="SupplierCode" UniqueName="SupplierCode" SortExpression="SupplierCode" FilterControlAltText="Filter SupplierCode column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="MessageStatus" HeaderText="MessageStatus" UniqueName="MessageStatus" SortExpression="MessageStatus" FilterControlAltText="Filter MessageStatus column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="DocumentType" HeaderText="DocumentType" UniqueName="DocumentType" FilterControlAltText="Filter DocumentType column" SortExpression="DocumentType"> </telerik:GridBoundColumn> <telerik:GridDateTimeColumn UniqueName="InvoiceCreationDate" DataField="InvoiceCreationDate" HeaderText="InvoiceCreationDate" FilterControlAltText="Filter InvoiceCreationDate column" SortExpression="InvoiceCreationDate"> <FilterTemplate> <telerik:RadDatePicker ID="RadDatePicker1" runat="server"> </telerik:RadDatePicker> </FilterTemplate> </telerik:GridDateTimeColumn> <%--<telerik:GridBoundColumn DataField="InvoiceCreationDate" DataType="InvoiceCreationDate" FilterControlAltText="Filter InvoiceCreationDate column" HeaderText="InvoiceCreationDate" SortExpression="InvoiceCreationDate" UniqueName="InvoiceCreationDate"> </telerik:GridBoundColumn>--%> <telerik:GridBoundColumn DataField="SupplierVatNumber" FilterControlAltText="Filter SupplierVatNumber column" HeaderText="SupplierVatNumber" SortExpression="SupplierVatNumber" UniqueName="SupplierVatNumber"> </telerik:GridBoundColumn> </Columns> <%--<EditFormSettings ColumnNumber="2" CaptionFormatString="Edit details for invoice with SequencialNumber {0}" CaptionDataField="SequencialNumber"> <FormTableItemStyle Wrap="False"></FormTableItemStyle> <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> <FormMainTableStyle CellSpacing="0" CellPadding="3" Width="100%" /> <FormTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="2" CssClass="module" Height="110px" Width="100%" /> <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> <FormStyle Width="100%" BackColor="#EEF2EA"></FormStyle> <EditColumn UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit"> </EditColumn> <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> </EditFormSettings>--%> <ExpandCollapseColumn Visible="False"> <HeaderStyle Width="19px"></HeaderStyle> </ExpandCollapseColumn> <RowIndicatorColumn Visible="False"> <HeaderStyle Width="20px" /> </RowIndicatorColumn> </MasterTableView> <FilterMenu EnableImageSprites="False"> </FilterMenu> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> </telerik:RadGrid> <%-- <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:EscalonamentoFacturasConnectionString %>" SelectCommand="SELECT [SequencialNumber], [Priority],[Process], [SupplierCode], [MessageStatus], [DocumentType],[InvoiceCreationDate], [SupplierVatNumber] FROM [SapDocuments] WHERE [Process] IN ('S','SP');"></asp:SqlDataSource>--%> </div> <br /> <br /> <br /> <br /> <br /> </asp:Content><%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="GridShowMenuExample._Default" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"></asp:Content><asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <asp:Panel ID="Panel1" BackColor="LightSalmon" runat="server"> <asp:Label ID="Label1" Text="Example Checkboxes: " runat="server"></asp:Label> <asp:CheckBox ID="CheckBox1" Text="Alpha" OnCheckedChanged="onHideShowCheckboxChange" runat="server" AutoPostBack="true" Checked="true" /> <asp:CheckBox ID="CheckBox2" Text="Beta" OnCheckedChanged="onHideShowCheckboxChange" runat="server" AutoPostBack="true" Checked="true" /> <asp:CheckBox ID="CheckBox3" Text="Gamma" OnCheckedChanged="onHideShowCheckboxChange" runat="server" AutoPostBack="true" Checked="true" /> <br /> <telerik:RadMenu ID="HideShowMenuRoot" runat="server" ClickToOpen="true" SkinID="WebBlue"> <Items> <telerik:RadMenuItem ID="HideShowMenu" runat="server" PostBack="False" Text="Hide/Show Columns"> </telerik:RadMenuItem> </Items> </telerik:RadMenu> <br /> <br /> </asp:Panel> <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0" GridLines="None" OnNeedDataSource="radGrid_onNeedDataSource"> <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True"> <Scrolling AllowScroll="True" UseStaticHeaders="True" /> </ClientSettings> <MasterTableView> <%-- Autogenerated stuff --%> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"> </RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"> </ExpandCollapseColumn> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"> </EditColumn> </EditFormSettings> <%-- End Autogenerated Stuff --%> <Columns> <telerik:GridBoundColumn DataField="Alpha" HeaderText="Alpha" SortExpression="Alpha" UniqueName="Alpha" FilterControlAltText="Filter Alpha column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Beta" HeaderText="Beta" SortExpression="Beta" UniqueName="Beta" FilterControlAltText="Filter Beta column"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Gamma" HeaderText="Gamma" SortExpression="Gamma" UniqueName="Gamma" FilterControlAltText="Filter Gamma column"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <FilterMenu EnableImageSprites="False"> </FilterMenu> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> </telerik:RadGrid></asp:Content>using System;using System.Collections.Generic;using System.Web.UI.WebControls;using Telerik.Web.UI;namespace GridShowMenuExample { public partial class _Default : System.Web.UI.Page { protected override void OnInit(EventArgs args) { //Menu Generator foreach (GridColumn col in RadGrid1.Columns) { var item = new RadMenuItem(); item.Text = col.UniqueName; HideShowMenu.Items.Add(item); } HideShowMenuRoot.ItemClick += new RadMenuEventHandler((clicksrc, clickargs) => { var menu = clicksrc as RadMenu; var col = RadGrid1.Columns.FindByUniqueName(menu.SelectedItem.Text); col.Visible = !col.Visible; }); } protected void Page_Load(object sender, EventArgs e) { } protected void radGrid_onNeedDataSource(object source, GridNeedDataSourceEventArgs e) { IList<ExampleClass> data = new List<ExampleClass>(); data.Add(new ExampleClass {Alpha = "Stuff", Beta="Things", Gamma=42}); data.Add(new ExampleClass {Alpha = "Stuff", Beta="Things", Gamma=42}); data.Add(new ExampleClass {Alpha = "Stuff", Beta="Things", Gamma=42}); data.Add(new ExampleClass {Alpha = "Stuff", Beta="Things", Gamma=42}); RadGrid1.DataSource = data; } protected void onHideShowCheckboxChange(object source, EventArgs args) { var box = source as CheckBox; var col = RadGrid1.Columns.FindByUniqueName(box.Text); col.Visible = box.Checked; } private class ExampleClass { public string Alpha { get; set; } public string Beta { get; set; } public int Gamma { get; set; } } }}