?
Solved

Assign values to the Text Field Crystal Report

Posted on 2007-11-30
14
Medium Priority
?
2,229 Views
Last Modified: 2013-12-16
    In our project, we are using crystal reports. Now I want to add the values which is getting from the .cs page to the Text Field presented in the crystal report page. How can I do this?
we are currently using front end Microsoft Visual studio 2005 and back end Microsoft SQL server 2005.
0
Comment
Question by:veradist
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
14 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 20381736
0
 
LVL 1

Author Comment

by:veradist
ID: 20382741
Your given solution is in vb.net. But I want to know in C#.net. So, please give me the solution with the code of ASP.net with C#.net 2005.

Thanks in Advance...
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 20383088
Add semi-colons to the end of each line and you are almost done! You basically need one line:

(CrystalDecisions.CrystalReports.Engine.TextObject)mrptDoc.ReportDefinition.ReportObjects(vstrTextObject).Text = _
vstrTextValue;

And it doesn't matter Windows or Web.
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 1

Author Comment

by:veradist
ID: 20383494
(CrystalDecisions.CrystalReports.Engine.TextObject)mrptDoc.ReportDefinition.ReportObjects(vstrTextObject).Text = _vstrTextValue;

From the above code  .Text does not pop up in my asp.net with c# and then _vstrTextValue also doesn't appear.
pls give me the feasible solution

Thanks in Advance..
 private void ApplyTextObject(string vstrTextObject, string vstrTextValue)
    {
        try
        {
            
            (CrystalDecisions.CrystalReports.Engine.TextObject)doc.ReportDefinition.ReportObjects(vstrTextObject) = vstrTextValue;
 
 
           
        }
        catch (Exception e)
        {
            System.Windows.Forms.MessageBox.Show("Catch here", "Message:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
        }
    }
 
   

Open in new window

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 20383621
I made a mistake. there shouldn't be any underscore there.

as for the text property, it is probably not the correct casting.
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 20383707
from http://www.csharpfriends.com/Forums/ShowPost.aspx?PostID=33132


CrystalDecisions.CrystalReports.Engine.TextObject HeaderCohort = ((CrystalDecisions.CrystalReports.Engine.TextObject)rpt.ReportHeaderSection1.ReportObjects["HeaderCohort"]); 
 
HeaderCohort.Text = "This is what I want it to Say Now"; 

Open in new window

0
 
LVL 1

Author Comment

by:veradist
ID: 20383848
Ok now there is no error it runs well but it goes to the exception part. I haven't reach the solution
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 20383946
and what is the exception? are you sure the field exists and it is spelled correctly?
0
 
LVL 1

Author Comment

by:veradist
ID: 20383978
The Exception is System.IndexOutOfRangeException: Index was outside the bounds of the array. at CrystalDecesions.CrystalReports.Engine.ReportObjects.get_Item(String Name) at Report.ApplyTextObject(String vstrTextObject, String vstrTextValue)in c:\Inetpub\wwwroot\Dashboard\Report.aspx.cs:line 52

This is the exception, now what can I do help me its very urgent
0
 
LVL 1

Author Comment

by:veradist
ID: 20384017
And my function is the following code snippet.
Then the calling function is

ApplyTextObject("txtInt_1", "Santhana Krishnan");
where txtInt_1 is the name of the TextObject and the "Santhana Krishnan" is the label which is appear to that particular TextObject.
private void ApplyTextObject(string vstrTextObject, string vstrTextValue)
    {
        try
        {
            CrystalDecisions.CrystalReports.Engine.TextObject HeaderCohort = ((CrystalDecisions.CrystalReports.Engine.TextObject)doc.ReportDefinition.ReportObjects["HeaderCohort"]);
            HeaderCohort.Text = "Veradis Technologies";
        }
        catch (Exception e)
        {
            System.Windows.Forms.MessageBox.Show("Catch here   -  "+e, "Message:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
        }
    }

Open in new window

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 20384049
the code posted is not using your variables!

this one is:
private void ApplyTextObject(string vstrTextObject, string vstrTextValue)
    {
        try
        {
            CrystalDecisions.CrystalReports.Engine.TextObject HeaderCohort = ((CrystalDecisions.CrystalReports.Engine.TextObject)doc.ReportDefinition.ReportObjects[vstrTextObject]);
            HeaderCohort.Text = vstrTextValue;
        }
        catch (Exception e)
        {
            System.Windows.Forms.MessageBox.Show("Catch here   -  "+e, "Message:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
        }
    }

Open in new window

0
 
LVL 1

Author Comment

by:veradist
ID: 20384110
Ya now its working
Thanks & very kind of u....
Thanks a lot sir.

0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 2000 total points
ID: 20386271
If it is working, you should accept a comment to close it
0
 
LVL 1

Author Closing Comment

by:veradist
ID: 31411893
Its a very timely help.
Thanks a lot to Expert Exchange...
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question