Hello Sir, It shows the below error.Please help with this,
System.NullReferenceException: 'Object reference not set to an instance of an object.'
System.Web.SessionState.HttpSessionState.this[string].get returned null.
Interrupted_runs.aspx.cs:
public partial class interrupted_runs : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
public void BindGrid()
{
InterruptedRuns objservice = new InterruptedRuns();
List<Project> data = objservice.getall();
if (data != null)
{
gvInterrupted.DataSource = data;
gvInterrupted.DataBind();
Session["RecordCountRows"] = gvInterrupted.Rows.Count;
gvInterrupted.DataBind();
// gvInterrupted.BottomPagerRow.Visible = true;
}
}
}
}
InterruptedRuns.cs:
namespace Vifex.DAL.Repository.Services
{
public class InterruptedRuns
{
public List<Project> getall()
{
List<Project> file = new List<Project>();
using (VifexDBEntities dbContext = new VifexDBEntities())
{
file = dbContext.Projects.Where(x=> x.Status.ToLower() == "error").ToList();
return file;
}
}
}
}
The page where count is to be shown in label:
public partial class Dashboard : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
VifexDBEntities entity = new VifexDBEntities();
var result = (from proj in entity.Projects
select proj);
lblTotal.Text = result.Count().ToString();
//var projectProjectRunning = "SELECT * FROM [InterruptedRuns]";
//var projectProjectInterrupted = "SELECT * FROM [gvInterrupted]";
//lblrunning.Text = projectProjectRunning.Count().ToString();
lblInterrupted.Text = Session["RecordCountRows"].ToString();
}
public void BindGrid()
{
DashboardService getdata = new DashboardService();
var project = getdata.getall();
DashboardGV.DataSource = project;
DashboardGV.DataBind();
}
Please tell me where is the value assigned to session.