HI Dharmendr Sir;
i have run the code of google line chart and got an error;
Error:
Error 1 An object reference is required for the non-static field, method, or property 'redirectAnotherPageLineChart.WebForm1.Type.get'
my code is here:
c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
namespace redirectAnotherPageLineChart
{
public partial class WebForm1 : System.Web.UI.Page
{
protected string Type { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Type = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["Type"]) ? HttpContext.Current.Request.QueryString["Type"] : "0";
}
}
[WebMethod]
public static List<object> GetChartData(string ipAddress)
{
string query = string.Format("SELECT [pingtime],[average] FROM [dbo].[graph] WHERE ipaddress='{0}' AND CONVERT(DATE,pingtime,103) BETWEEN CONVERT(DATE,DATEADD(DAY, -7, GETDATE()),103) AND CONVERT(DATE,GETDATE(),103) ORDER BY CONVERT(DATETIME,pingtime,103) ASC", ipAddress); ;
switch (Type)
{
case "1":
query = string.Format("SELECT [pingtime],[average] FROM [dbo].[graph] WHERE ipaddress='{0}' AND CONVERT(DATE,pingtime,103) BETWEEN CONVERT(DATE,DATEADD(MONTH, -1, GETDATE()),103) AND CONVERT(DATE,GETDATE(),103) ORDER BY CONVERT(DATETIME,pingtime,103) ASC", ipAddress);
break;
case "2":
query = string.Format("SELECT [pingtime],[average] FROM [dbo].[graph] WHERE ipaddress='{0}' AND CONVERT(DATE,pingtime,103) BETWEEN CONVERT(DATE,DATEADD(MONTH, -2, GETDATE()),103) AND CONVERT(DATE,GETDATE(),103) ORDER BY CONVERT(DATETIME,pingtime,103) ASC", ipAddress);
break;
case "3":
query = string.Format("SELECT [pingtime],[average] FROM [dbo].[graph] WHERE ipaddress='{0}' AND CONVERT(DATE,pingtime,103) BETWEEN CONVERT(DATE,DATEADD(MONTH, -6, GETDATE()),103) AND CONVERT(DATE,GETDATE(),103) ORDER BY CONVERT(DATETIME,pingtime,103) ASC", ipAddress);
break;
default:
break;
}
string constr = ConfigurationManager.ConnectionStrings["dbcs"].ConnectionString;
List<object> chartData = new List<object>();
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
chartData.Add(new object[] { Convert.ToDateTime(sdr["pingtime"]), sdr["average"] });
}
}
con.Close();
return chartData;
}
}
}
}
}
please help me to fix it.