I am getting two errors for a piece a code which seems fairly straight-forward. I am working on a C#/ASP.NET app. I have a control that sits in my Template.Master and once the user logs in, presents a list of clients the user is tracking.
Code behind page for control
The errors are returned referencing this code. Specifically this line:
with the error NWC.CSWeb.BLL.Program.TrackedClient.GetTrackedClientCount(string) is a method, which is not valid in the given context.
The second error comes the line:
With the error Cannot convert method group to non-delegate type object. Did you intend to invoke a method?
From BLL.Program.TrackedClient.CS
From SQLProvider
I am not proficient with C#, but this seems straightforward to me. The Stored Procedure returns and integer. If the value is greater than 0, return the list of clients using GetTrackedClients, else, show the label for no tracked clients.
Any help would be appreciated. Even a more definitive description of the two errors, and whether or not they are related to each other, or represent two different errors in the code.
Code behind page for control
The errors are returned referencing this code. Specifically this line:
Code:
(NWC.CSWeb.BLL.Program.TrackedClient.GetTrackedClientCount.Value > 0)
The second error comes the line:
Code:
repTrackedClient.DataSource = NWC.CSWeb.BLL.Program.TrackedClient.GetTrackedClients
Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NWC.CSWeb;
using NWC.CSWeb.BLL.Program;
using NWC.CSWeb.UI;
namespace NWC.CSWeb.UI.Controls
{
public partial class TrackedClientBox : BaseWebPart
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
if (NWC.CSWeb.BLL.Program.TrackedClient.GetTrackedClientCount.Value > 0)
{
repTrackedClient.DataSource = NWC.CSWeb.BLL.Program.TrackedClient.GetTrackedClients;
repTrackedClient.DataBind();
panLinkTrackedClients.Visible = true;
lblNoTrackedClients.Visible = false;
}
else
{
panLinkTrackedClients.Visible = false;
lblNoTrackedClients.Visible = true;
}
}
}
}
}
From BLL.Program.TrackedClient.CS
Code:
/// <summary>
/// Returns the number of Tracked Clients for the current user
/// </summary>
public static int GetTrackedClientCount(string addedBy)
{
int trackedClientCount = 0;
string key = "Program_TrackedClientCount_" + addedBy;
if (BaseProgram.Settings.EnableCaching && BizObject.Cache[key] != null)
{
trackedClientCount = (int)BizObject.Cache[key];
}
else
{
trackedClientCount = SiteProvider.Program.GetTrackedClientCount(addedBy);
BaseProgram.CacheData(key, trackedClientCount);
}
return trackedClientCount;
}
Code:
/// <summary>
/// Returns the number of Tracked Clients for the current user
/// </summary>
public override int GetTrackedClientCount(string addedBy)
{
using (SqlConnection cn = new SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new SqlCommand("nwc_Program_GetTrackedClientCount", cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@AddedBy", SqlDbType.NVarChar).Value = addedBy;
cn.Open();
return (int)ExecuteScalar(cmd);
}
}
I am not proficient with C#, but this seems straightforward to me. The Stored Procedure returns and integer. If the value is greater than 0, return the list of clients using GetTrackedClients, else, show the label for no tracked clients.
Any help would be appreciated. Even a more definitive description of the two errors, and whether or not they are related to each other, or represent two different errors in the code.