veradist
asked on
Assign values to the Text Field Crystal Report
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.
we are currently using front end Microsoft Visual studio 2005 and back end Microsoft SQL server 2005.
see "Passing a value to a report object" from http://www.emoreau.com/Entries/Articles/2006/09/Feeding-Crystal-Reports-from-your-application.aspx
ASKER
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...
Thanks in Advance...
Add semi-colons to the end of each line and you are almost done! You basically need one line:
(CrystalDecisions.CrystalR eports.Eng ine.TextOb ject)mrptD oc.ReportD efinition. ReportObje cts(vstrTe xtObject). Text = _
vstrTextValue;
And it doesn't matter Windows or Web.
(CrystalDecisions.CrystalR
vstrTextValue;
And it doesn't matter Windows or Web.
ASKER
(CrystalDecisions.CrystalR eports.Eng ine.TextOb ject)mrptD oc.ReportD efinition. ReportObje cts(vstrTe xtObject). 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..
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);
}
}
I made a mistake. there shouldn't be any underscore there.
as for the text property, it is probably not the correct casting.
as for the text property, it is probably not the correct casting.
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";
ASKER
Ok now there is no error it runs well but it goes to the exception part. I haven't reach the solution
and what is the exception? are you sure the field exists and it is spelled correctly?
ASKER
The Exception is System.IndexOutOfRangeExce ption: Index was outside the bounds of the array. at CrystalDecesions.CrystalRe ports.Engi ne.ReportO bjects.get _Item(Stri ng Name) at Report.ApplyTextObject(Str ing vstrTextObject, String vstrTextValue)in c:\Inetpub\wwwroot\Dashboa rd\Report. aspx.cs:li ne 52
This is the exception, now what can I do help me its very urgent
This is the exception, now what can I do help me its very urgent
ASKER
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.
Then the calling function is
ApplyTextObject("txtInt_1"
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);
}
}
the code posted is not using your variables!
this one is:
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);
}
}
ASKER
Ya now its working
Thanks & very kind of u....
Thanks a lot sir.
Thanks & very kind of u....
Thanks a lot sir.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Its a very timely help.
Thanks a lot to Expert Exchange...
Thanks a lot to Expert Exchange...