Click here to Skip to main content
15,892,805 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello. I have a web form that has crystal report viewer on it and I added a textbox to the form also. When I run the form I get this text that appears in the textbox. It says this: "System.Web.UI.WebControls.TextBox". Why does this happen? I use the textbox to display the session ID that I want to make sure it will display what I need. Here is the code for that form.

C#
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using CrystalDecisions.Web;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Xml.Linq;
using System.Web.SessionState;


namespace SACSCOCLogin1._1
{
    public partial class ReportFormA : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            TextBoxINST_ID.Text = Session["inst_id"].ToString();
            CrystalReportViewer1.Visible = true;
            //CrystalReportViewer1.Refresh();
            ReportDocument crystalReport = new ReportDocument();
            crystalReport.Load(Server.MapPath("~/Reports/ReportA.rpt"));
            crystalReport.SetDatabaseLogon
            ("Administrator", "losni", @"cocsql", "Password");
            CrystalReportViewer1.ReportSource = crystalReport;
            CrystalReportViewer1.SelectionFormula = "{TableCOCINST.LongName} = 'INST_ID' AND {TableCOCINST.STATE} = 'INST_ID' AND {TableCOCINST.CITY} = 'INST_ID'";
            //CrystalReportViewer1.SelectionFormula = "{TableFIN2013.inst_id} = '" + Session["inst_id"].ToString() + "'";
        }
Posted
Comments
Maarten Kools 20-Feb-14 13:17pm    
How do you store the variable in Session["inst_id"]? It's probably another TextBox control. When you call ToString() of a TextBox, you'll get that particular string.
Computer Wiz99 20-Feb-14 14:08pm    
Well, This is what holds my session, "TextBoxINST_ID.Text = Session["inst_id"].ToString();" but when I run the program I get this error: "Conversion failed when converting the varchar value 'System.Web.UI.WebControls.TextBox' to data type int.". Why is that and how do I fix it?

1 solution

I solved it!! I just removed the crystalreportviewer and added the Textbox to the form and put the crystalreportviewer under the textbox. No error.
 
Share this answer
 
Comments
Maarten Kools 21-Feb-14 1:01am    
Oh good you solved it yourself. Not sure what went wrong before though.
VICK 21-Feb-14 2:08am    
DO Share the code so that the other could get the clear idea and help if required in future.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900