How to use variable value in method in stimulsoft

Stimulsoft Reports.WEB discussion
Post Reply
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

How to use variable value in method in stimulsoft

Post by m.issa »

Hello

please how i can use variable value in created method in stimulsoft? i created string variable in stimulsoft under the name (DateFormat), and in my C# code i pass the value for this variable as the following :
report["DateFormat"] = Session["DateFormat"].ToString();

in my stimulsoft code i created the following code to use the value of this variable and return the result to the text box:

Code: Select all

public string strTodt(DateTime strDate)
		{
			string dateFormat = Convert.ToString(Dictionary.Variables["DateFormat"]);
			string stringDate = strDate.ToString(dateFormat);
			return stringDate;
		}
but this generated the following error:

error CS0119: 'Stimulsoft.Report.StiReport.Convert(Stimulsoft.Report.Units.StiUnit, Stimulsoft.Report.Units.StiUnit)' is a 'method', which is not valid in the given context


but if i use in my method direct value the report run properly, as the following:

Code: Select all

public string strTodt(DateTime strDate)
		{
			string stringDate = strDate.ToString("dd,MM,yyyy");
			return stringDate;
		}
so how i can do that ( pass value to variable from my C# code into my method inside stimulsoft code) please?

Thank you
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to use variable value in method in stimulsoft

Post by Alex K. »

Hello,

Try to use the following code:

Code: Select all

string dateFormat = System.Convert.ToString(Dictionary.Variables["DateFormat"]);
Thank you.
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

Re: How to use variable value in method in stimulsoft

Post by m.issa »

Hello

It is working now, really thanks a lot.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: How to use variable value in method in stimulsoft

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply