5
Answers

How to solve problem Object refreance is not set at instante

sagar Bhosale

sagar Bhosale

13y
2.4k
1
Hi friends, I genrate report in asp.net but i got run time error that object refrance is not set at instance 

when i click GenrateReport button javascript function is call window open which is shoe error i post screenshot
how to solve this problem

Thanks

my code is
GenerateReport.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using System.Data;
using System.Configuration;
using System.Globalization;
using System.IO;




using Radar.BusinessObjects;
using Radar.Utilities;
using Radar.Controller;


namespace Radar.WebApp.Report {
public partial class GenerateReport : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {


if (!IsPostBack) {


generate();
}


}






public void generate() {


string response = string.Empty;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
IFormatProvider format = new CultureInfo("en-US");
DateTime fromDate = DateTime.Parse(Request.QueryString["fromDate"].Trim(), format, DateTimeStyles.None);
DateTime toDate = DateTime.Parse(Request.QueryString["toDate"].Trim(), format, DateTimeStyles.None);
int edition = int.Parse(Request.QueryString["edition"].Trim());
int company = int.Parse(Request.QueryString["company"].Trim());
       


DataTable coverageResults = new DataTable();
MediaTrackController controller = new MediaTrackController();


coverageResults = controller.GenerateReportClient(fromDate,toDate,company, edition, int.Parse(Session["Group_id"].ToString())).Tables[0];


ReportDataSource coverageCountSource = new ReportDataSource("ClientReport");
coverageCountSource.Value = coverageResults;








rptViewer.LocalReport.ReportPath = "Report/ReportClient.rdlc";
rptViewer.LocalReport.DataSources.Add(coverageCountSource);



rptViewer.LocalReport.EnableExternalImages = true;
rptViewer.ProcessingMode = ProcessingMode.Local;
rptViewer.LocalReport.Refresh();
}
}
}


MediaTrackController.aspx.cs
public DataSet GenerateReportClient(DateTime fromDate, DateTime toDate, int company, int edition, int group) {
try {
NewsLetterContext context = new NewsLetterContext();
return context.GenerateReportClient(fromDate, toDate, company, edition, group);


} catch (RadarException ex) {

throw ex;
} catch (Exception ex) {

throw ex;
} finally {
//nothing to do
}
}



Attachment: sagar.rar

Answers (5)