User1815352578 posted
I'm using the .netcharting component to display graphs on my .aspx page. I have code samples which works without using the codebehind option. When i try to load the graph using a sub Page_Load in a codebehind.vb it doesn't work. Would anyone be able to transform
this code, (which i use in a script tag in the head of the aspx page) to code that works in the codebehind page? I think it's because of the namespaces i use. Please help. I've been stuck on this for ages and can't go any further till it's complete.
<%@ Page Language="VB" debug="true" trace="false" Description="dotnetCHARTING Component"%> <%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Data"
%> <%@ Import Namespace="System.Data.OleDb" %> <script runat="server"> sub Page_Load(sender As Object ,e As EventArgs ) 'set global properties Chart.Title="Scatter sample" Chart.DefaultSeries.ConnectionString = "server=delphi;user=db0426user;database=db0426"
Chart.TempDirectory="temp" Chart.Debug=true Chart.Type=ChartType.Scatter 'Chart.DefaultSeries.DefaultElement.ShowValue=true Chart.DefaultSeries.DefaultElement.LabelTemplate="(%Xvalue,%Yvalue)" 'Adding series programatically Chart.Series.Name = "Series 1" Chart.Series.SqlStatement
= "SELECT * FROM OWCDATA" Chart.Series.DataFields="xaxis=Y,yaxis=X,tooltip=ToolTip" Chart.Series.Type = SeriesType.Spline Chart.SeriesCollection.Add() End Sub </script> <HTML><HEAD><TITLE>Scatter sample</TITLE></HEAD> <BODY>
User1815352578 posted
code behind Imports Microsoft.VisualBasic Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Configuration Imports System.Data Imports System.Data.SqlClient Imports System.Configuration.ConfigurationSettings Imports System.Drawing
Imports dotnetCHARTING Public Class admin_view_solutions Inherits Page sub Page_Load(sender As Object ,e As EventArgs ) 'set global properties Chart.Title="Scatter sample" Chart.DefaultSeries.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;user id=admin;password=;data
source=" & Server.MapPath("../../database/chartsample.mdb") Chart.TempDirectory="temp" Chart.Debug=true Chart.Type=ChartType.Scatter Chart.DefaultSeries.DefaultElement.ShowValue=true Chart.DefaultSeries.DefaultElement.LabelTemplate="(%Xvalue,%Yvalue)" 'Adding
series programatically Chart.Series.Name = "Series 1" Chart.Series.SqlStatement = "SELECT * FROM SampleData" Chart.Series.DataFields="xaxis=X,yaxis=Y,tooltip=ToolTip" Chart.Series.Type = SeriesType.Spline Chart.SeriesCollection.Add() End Sub End Class
I have no idea how to use or what the namespaces mean or what the 'Register TagPrefix="dotnet"' does. Please HELP? Thanks for the reply
User1815352578 posted
I've been playing around and am now using the following namespaces: Imports Microsoft.VisualBasic Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Configuration Imports System.Data Imports System.Data.SqlClient Imports System.Configuration.ConfigurationSettings
Imports System.Drawing Imports System.Web.UI.WebControls.WebControl But i'm getting the following error: BC30451: Name 'ChartType' is not declared. Line x: Chart.Type=ChartType.Scatter What namespace to i have to use to get rid of this?
User1815352578 posted
When i import that line it gives me the error: BC30561: 'Label' is ambiguous, imported from the namespaces or types 'dotnetCHARTING, System.Web.UI.WebControls'. Line 29: Protected WithEvents BasicDataLabel As Label I have no idea what this means. I'll post
the entire code. Imports Microsoft.VisualBasic Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Configuration Imports System.Data Imports System.Data.SqlClient Imports System.Configuration.ConfigurationSettings Imports System.Drawing
Imports System.Web.UI.WebControls.WebControl Imports System.Drawing.Drawing2D Imports System.Object Imports System.Collections Imports dotnetCHARTING Public Class admin_view_solutions Inherits Page Protected WithEvents solution_id As DropDownList 'Protected
WithEvents group_name As DropDownList Protected WithEvents basicDataGrid As DataGrid Protected WithEvents LecturerDataGrid As DataGrid Protected WithEvents studentDataGrid As DataGrid Protected WithEvents StudentDataListDisplay As DataList Protected WithEvents
BasicDataLabel As Label Protected WithEvents StudentDataLabel As Label Protected WithEvents LecturerDataLabel As Label Protected WithEvents AddSolutionLabel As Label Protected WithEvents Add As Button Protected WithEvents Chart As dotnetCHARTING.Chart 'Protected
WithEvents ChartType As Type Dim DBConnection As SQLConnection Dim DBCommand1 As SqlCommand Dim DBCommand2 As SqlCommand Dim DBCommand3 As SqlCommand Dim DBCommand4 As SqlCommand Dim DBCommand5 As SqlCommand Dim DBCommand6 As SqlCommand Dim DBCommand7 As SqlCommand
Dim DBReader As SqlDataReader Dim SQLString As String Sub Page_Load(ByVal Src As Object, ByVal Args As System.EventArgs ) If Not Page.IsPostBack Then '-- Load drop-down list with Solution ID's -- DBConnection = New SqlConnection( "Server=delphi; Database=db0426;user=db0426user;")
DBConnection.Open() SQLString = "SELECT DISTINCT solution_id FROM allocations ORDER BY solution_id" DBCommand1 = New SqlCommand(SQLString, DBConnection) DBReader = DBCommand1.ExecuteReader() solution_id.DataSource = DBReader solution_id.DataTextField = "solution_id"
solution_id.DataValueField = "solution_id" solution_id.DataBind() DBReader.Close() DBConnection.Close() 'group_name.Visible = False 'BrowseBasicData.Visible = False 'set global properties of chart Chart.Title="Pareto Front" Chart.DefaultSeries.ConnectionString
= "server=delphi;user=db0426user;database=db0426" Chart.TempDirectory="temp" Chart.Debug=true Chart.Type=ChartType.Scatter 'Chart.DefaultSeries.DefaultElement.ShowValue=true Chart.DefaultSeries.DefaultElement.LabelTemplate="(%Xvalue,%Yvalue)" 'Adding series
programatically Chart.Series.Name = "Series 1" Chart.Series.SqlStatement = "SELECT * FROM OWCDATA" Chart.Series.DataFields="xaxis=Y,yaxis=X,tooltip=ToolTip" 'Chart.Series.Type = SeriesType.Spline Chart.SeriesCollection.Add() End If End Sub Sub DisplayBasicResults(ByVal
Src As Object, ByVal Args As System.EventArgs) DBConnection = New SqlConnection( "Server=delphi; Database=db0426;user=db0426user;") SQLString = "SELECT Group_Name, Allocation, Lecturer_ID FROM allocations WHERE " & _ "solution_id = '" & solution_id.SelectedItem.Value
& "' ORDER BY group_name" DBConnection.Open() DBCommand2 = New SqlCommand(SQLString, DBConnection) DBReader = DBCommand2.ExecuteReader() basicDataGrid.DataSource = DBReader basicDataGrid.DataBind() BasicDataLabel.Text = "Basic Data" BasicDataLabel.Visible
= True DBReader.Close() SQLString = "SELECT first_preference, second_preference, third_preference, forth_preference, fifth_preference, sixth_preference FROM student_allocation_details WHERE " & _ "solution_id = '" & solution_id.SelectedItem.Value & "'" DBCommand3
= New SqlCommand(SQLString, DBConnection) DBReader = DBCommand3.ExecuteReader() StudentDataListDisplay.DataSource = DBReader StudentDataListDisplay.DataBind() StudentDataLabel.Text = "Student Data" StudentDataLabel.Visible = True DBReader.Close() SQLString
= "SELECT Lecturer_ID, Number_of_Projects_Supervised FROM lecturer_allocation_details_projects WHERE " & _ "solution_id = '" & solution_id.SelectedItem.Value & "' ORDER BY lecturer_id" DBCommand4 = New SqlCommand(SQLString, DBConnection) DBReader = DBCommand4.ExecuteReader()
LecturerDataGrid.DataSource = DBReader LecturerDataGrid.DataBind() LecturerDataLabel.Text = "Lecturer Data" LecturerDataLabel.Visible = True DBReader.Close() DBConnection.Close() AddSolutionLabel.Text="" End Sub Sub AddSolution(ByVal Src As Object, ByVal Args
As System.EventArgs) DBConnection = New SqlConnection( "Server=delphi; Database=db0426;user=db0426user;") DBCommand7 = New SqlCommand("INSERT INTO selected_solutions(solution_id) VALUES (@solution_id) ",DBConnection) DBCommand7.Parameters.Add("@solution_id",
solution_id.SelectedItem.Value) DBConnection.Open() DBCommand7.ExecuteNonQuery AddSolutionLabel.Text="Solution added to Cart" AddSolutionLabel.Visible = True 'basicDataGrid.Visible=False 'LecturerDataGrid.Visible=False 'studentDataGrid.Visible=False StudentDataListDisplay.Visible=False
'BasicDataLabel.Visible=False 'StudentDataLabel.Visible=False 'LecturerDataLabel.Visible=False DBConnection.Close() End Sub End Class
User-85647200 posted
You're declaring several controls as "Label" and the compiler doesn't know what type of Label you want. Try Protected WithEvents BasicDataLabel As System.Web.UI.WebControls.Label Protected WithEvents StudentDataLabel As System.Web.UI.WebControls.Label Protected
WithEvents LecturerDataLabel As System.Web.UI.WebControls.Label Protected WithEvents AddSolutionLabel As System.Web.UI.WebControls.Label If that doesn't work, try Protected WithEvents BasicDataLabel As dotnetCHARTING.Label Protected WithEvents StudentDataLabel
As dotnetCHARTING.Label Protected WithEvents LecturerDataLabel As dotnetCHARTING.Label Protected WithEvents AddSolutionLabel As dotnetCHARTING.Label