sales dashboard

2 posts, 0 answers
  1. Saed
    Saed avatar
    6 posts
    Member since:
    Mar 2013

    Posted 25 Apr 2013 Link to this post

    Hi
    i have question when i change from C# to vb  in default.aspx   the loaded control in content work but the problem  if i sort the datagrid its disappear ,same code for c# work Fine sort grid filtering .... ,  but when translate to vb this problem come ,  so i thing problem here when i make translation to vb



     C# Code
    using System;
    using System.Configuration;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Web.UI;
    using System.Web.UI.WebControls;
     
    using Telerik.Web.UI;
    using Telerik.Web.UI.Calendar;
     

    public partial class _Default : Page, IViewSelector
    {
        private const string ViewsFolder = "~/Views/";
        private const string DefaultContentControl = "Statistics.ascx";

        private string LoadedControlName
        {
            get
            {
                return (string)ViewState["LoadedControlName"] ?? DefaultContentControl;
            }

            set
            {
                ViewState["LoadedControlName"] = value;
            }
        }

        private int EmployeeID
        {
           

            get
            {
                if (Session["EmployeeID"] == null)
                {
                    Session["EmployeeID"] = 1;
                }

                return (int) Session["EmployeeID"];
            }
            set
            {
                Session["EmployeeID"] = value;
            }
        }

        private DateTime StartDate
        {
            get
            {
                return StartDatePicker.SelectedDate.Value;
            }
        }

        private DateTime EndDate
        {
            get
            {
                return EndDatePicker.SelectedDate.Value;
            }
        }

        

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                EmployeesListView.Rebind();
                EmployeesListView.SelectedIndexes.Add(0);
            }
            LoadContent();
        }

        public void SelectView(string viewName)
        {
            var tab = ViewChooser.Tabs.FindTabByText(viewName);
            if (tab != null)
                tab.Selected = true;

            UpdateSelectedView();
        }

        protected void ViewChooser_TabClick(object sender, RadTabStripEventArgs e)
        {
            UpdateSelectedView();
        }

        private void LoadContent()
        {
            var control = LoadControl(ViewsFolder + LoadedControlName);
            control.ID = "contentControl";
            var contentControl = control as IContentControl;

            if (contentControl != null)
            {
                contentControl.EmployeeID = EmployeeID; // from ListView
                contentControl.StartDate = StartDate;
                contentControl.EndDate = EndDate;
            }

            var userDetailsPanel = (UserDetails) as IContentControl;
            userDetailsPanel.EmployeeID = EmployeeID;
            userDetailsPanel.StartDate = StartDate;
            userDetailsPanel.EndDate = EndDate;

            Content.Controls.Clear();
            Content.Controls.Add(control);
        }

        protected void UpdateSelectedView()
        {
            string selectedControl = ViewChooser.SelectedTab.Value;
            if (selectedControl != LoadedControlName)
            {
                LoadedControlName = selectedControl;
                LoadContent();
            }
        }

        public string GetSalesPercentage(int employeeID)
        {

            var empSales = 222;
            return (empSales * 100).ToString("F0");
        }

        protected void PagerSlider_ValueChanged(object sender, EventArgs e)
        {
            string newValue = (sender as RadSlider).Value.ToString();
            EmployeesListView.Items[0].FireCommandEvent(RadListView.PageCommandName, newValue);
        }

        protected void EmployeesListView_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
        {
           
        }

        protected void EmployeesListView_SelectedIndexChanged(object sender, EventArgs eventArgs)
        {
            EmployeeID = int.Parse(EmployeesListView.SelectedValue.ToString());     
            LoadContent();
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "hide", "HideLoadingPanel()", true);
        }

        protected override void OnPreRenderComplete(EventArgs e)
        {
            base.OnPreRenderComplete(e);

            // Make the EmployeeID available to scripts
            ScriptManager.RegisterStartupScript(Page, typeof(Page), "employeeID" ,
                "function getEmployeeID()    { return " + EmployeeID + "; }", true);
        }

        protected void SelectedDataChanged(object sender, SelectedDateChangedEventArgs e)
        {
            LoadContent();
        }
    }






    VB Code

    Imports System.Configuration
    Imports System.Data.SqlClient
    Imports System.Linq
    Imports System.Web.UI
    Imports System.Web.UI.WebControls

    Imports Telerik.Web.UI
    Imports Telerik.Web.UI.Calendar
    Partial Class Default3
        Inherits Page
        Implements IViewSelector
        Private Const ViewsFolder As String = "~/Views/"
        Private Const DefaultContentControl As String = "Statistics.ascx"

        Private Property LoadedControlName() As String
            Get
                Return If(DirectCast(ViewState("LoadedControlName"), String), DefaultContentControl)
            End Get

            Set(value As String)
                ViewState("LoadedControlName") = value
            End Set
        End Property

        Private Property EmployeeID() As Integer


            Get
                If Session("EmployeeID") Is Nothing Then
                    Session("EmployeeID") = 1
                End If

                Return CInt(Session("EmployeeID"))
            End Get
            Set(value As Integer)
                Session("EmployeeID") = value
            End Set
        End Property

        Private ReadOnly Property StartDate() As DateTime
            Get
                Return StartDatePicker.SelectedDate.Value
            End Get
        End Property

        Private ReadOnly Property EndDate() As DateTime
            Get
                Return EndDatePicker.SelectedDate.Value
            End Get
        End Property



        Protected Sub Page_Load(sender As Object, e As EventArgs)
            If Not IsPostBack Then
                EmployeesListView.Rebind()
                EmployeesListView.SelectedIndexes.Add(0)
            End If
            LoadContent()
        End Sub

        Public Sub SelectView(viewName As String)
            Dim tab = ViewChooser.Tabs.FindTabByText(viewName)
            If tab IsNot Nothing Then
                tab.Selected = True
            End If

            UpdateSelectedView()
        End Sub

        Protected Sub ViewChooser_TabClick(sender As Object, e As RadTabStripEventArgs)
            UpdateSelectedView()
        End Sub

        Private Sub LoadContent()
            Dim control = LoadControl(ViewsFolder & LoadedControlName)
            control.ID = "contentControl"
            Dim contentControl = TryCast(control, IContentControl)

            If contentControl IsNot Nothing Then
                contentControl.EmployeeID = EmployeeID
                ' from ListView
                contentControl.StartDate = StartDate
                contentControl.EndDate = EndDate
            End If

            Dim userDetailsPanel = TryCast(UserDetails, IContentControl)
            userDetailsPanel.EmployeeID = EmployeeID
            userDetailsPanel.StartDate = StartDate
            userDetailsPanel.EndDate = EndDate

            Content.Controls.Clear()
            Content.Controls.Add(control)
        End Sub

        Protected Sub UpdateSelectedView()
            Dim selectedControl As String = ViewChooser.SelectedTab.Value
            If selectedControl <> LoadedControlName Then
                LoadedControlName = selectedControl
                LoadContent()
            End If
        End Sub

        Public Function GetSalesPercentage(employeeID As Integer) As String

            Dim empSales = 222
            Return (empSales * 100).ToString("F0")
        End Function

        Protected Sub PagerSlider_ValueChanged(sender As Object, e As EventArgs)
            Dim newValue As String = TryCast(sender, RadSlider).Value.ToString()
            EmployeesListView.Items(0).FireCommandEvent(RadListView.PageCommandName, newValue)
        End Sub

        Protected Sub EmployeesListView_NeedDataSource(sender As Object, e As RadListViewNeedDataSourceEventArgs)

        End Sub

        Protected Sub EmployeesListView_SelectedIndexChanged(sender As Object, eventArgs As EventArgs)
            EmployeeID = Integer.Parse(EmployeesListView.SelectedValue.ToString())
            LoadContent()
            ScriptManager.RegisterStartupScript(Page, GetType(Page), "hide", "HideLoadingPanel()", True)
        End Sub

        Protected Overrides Sub OnPreRenderComplete(e As EventArgs)
            MyBase.OnPreRenderComplete(e)

            ' Make the EmployeeID available to scripts
            ScriptManager.RegisterStartupScript(Page, GetType(Page), "employeeID", "function getEmployeeID()" & vbTab & "{ return " & EmployeeID & "; }", True)
        End Sub

        Protected Sub SelectedDataChanged(sender As Object, e As SelectedDateChangedEventArgs)
            LoadContent()
        End Sub

    End Class








    error message :
    1.  Error    5    Overload resolution failed because no accessible 'Int' accepts this number of arguments.    C:\Users\Administrator\Documents\Visual Studio 2010\WebSites\abc\Default3.aspx    
    2. Error    7    Class 'Default3' must implement 'Sub SelectView(viewName As String)' for interface 'IViewSelector'.    C:\Users\Administrator\Documents\Visual Studio 2010\WebSites\abc\Default3.aspx.vb   

    so what i did

    1. replace  int by  integer .....so problem solved
    2. replace   Public Sub SelectView(viewName As String)    by         Public Sub SelectView(viewName As String)   Implements IViewSelector.SelectView         .....so problem solved

    but problem explained above occur, any suggestion ?...sorry for stretching

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 29 Apr 2013 Link to this post

    Hi Saed,

    Could you please provide the exact steps need top be performed to replicate the issue locally? Thus we could review the application's VB version of the source code and do our best to isolate the root cause of the issue and fix it in the uploaded source.

    Regards,
    Maria Ilieva
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top