Data Connectivity
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Data Connectivity
Message Icon Topic: displaying wrong records Post Reply Post New Topic
Author Message
vyasdipti
Newbie
Newbie
Avatar

Joined: 17 Nov 2008
Location: India
Online Status: Offline
Posts: 3
Quote vyasdipti Replybullet Topic: displaying wrong records
    Posted: 26 Nov 2008 at 2:21am

I have to show the  report of employee telephone numbers. So for this i gave two options:

1. All and 2. Employee wise.
 
In case 'Employee wise' radiobutton is clicked then one textbox will come where u will give employee id and all telephone numbers(residential cell / residential landline / personal cell / office number etc) of that particular employee will be displayed.
 
But in case the radiobutton 'All' is selected then all telephone numbers of all the employees will be displayed.
 
Here, i could do with both the things properly. For first time when i select the radiobutton of 'all' and click on show report it is displaying correct report giving telephone numbers of all the employees. Then when i select the radiobutton 'employee wise' and give the id of particular employee and click on button, then also particularly for that employee the report is displayed correctly.
 
but when i again come back to radiobutton 'all' after when once employee wise report is displayed, then in 'all' also same record is displayed and all records is not coming.
wat will be the reason for this? For your persual i m copy pasting the coding. Please get back to me with this at earliest.
 
 

protected void btnshow_Click(object sender, EventArgs e)

{

//rdbtcust is to show report customer wise

if (rdbtncust.Checked)

{

lblcustpk.Visible = true;

txtcustname.Visible = true;

btncustpk.Visible = true;

string custid = Session["custid"].ToString();

Response.Write(custid);

tblreport.Visible = true;

SqlDataAdapter dap = new SqlDataAdapter("select custid, fname, lname, restelno, mobileno, shopll, resmobno, others from tblcustgeneral where custid='" + custid + "'", con);

DataSet das = new DataSet();

dap.Fill(das);

ReportDocument rpt11 = new ReportDocument();

rpt11.Load(Server.MapPath("custwisetelno.rpt"));

rpt11.SetDataSource(das);

CrystalReportViewer1.SelectionFormula = "{tblcustgeneral.custid}=" + custid + "";

CrystalReportViewer1.ReportSource = rpt11;

CrystalReportViewer1.DataBind();

btnprint.Visible = true;

//custwisetotdeduction.rpt

}

//rdbtnall is to show report of all the customers

else if (rdbtnall.Checked)

{

SqlDataAdapter dap2 = new SqlDataAdapter("select custid, fname, lname, restelno, mobileno, shopll, resmobno, others from tblcustgeneral", con);

DataSet das2 = new DataSet();

dap2.Fill(das2);

ReportDocument rpt1 = new ReportDocument();

rpt1.Load(Server.MapPath("alltelno.rpt"));

rpt1.SetDataSource(das2);

tblreport.Visible = true;

CrystalReportViewer1.ReportSource = rpt1;

CrystalReportViewer1.DataBind();

btnprint.Visible = true;

}

}

 

protected void rdbtnall_CheckedChanged(object sender, EventArgs e)

{

Session["custid"] = null;

lblcustpk.Visible = false;

txtcustname.Visible = false;

btncustpk.Visible = false;

txtcustname.Text = "";

}

protected void rdbtncust_CheckedChanged(object sender, EventArgs e)

{

lblcustpk.Visible = true;

txtcustname.Visible = true;

btncustpk.Visible = true;

}

dIPTI vYAS
Arete Technologies Pvt Ltd
Sr.Systems Analyst
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 02 Dec 2008 at 12:32pm

It looks like you're using the same viewer for every load of the report.  You may need to close and dispose of the report in the viewer prior to loading a different report.  The code for this looks something like this:

If (CrystalReportViewer1.ReportSource != null)
{
 
  ((ReportDocument) CrystalReportViewer1.ReportSource).Close();
  ((ReportDocument) CrystalReportViewer1.ReportSource).Dispose();
}
 
I haven't tested this because we always open reports in new windows so we get a fresh viewer every time.  However, I think it will work.
 
-Dell
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.