Page 1 of 1

How to use variable value in method in stimulsoft

Posted: Wed Nov 21, 2012 8:06 am
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

Re: How to use variable value in method in stimulsoft

Posted: Thu Nov 22, 2012 9:37 am
by Alex K.
Hello,

Try to use the following code:

Code: Select all

string dateFormat = System.Convert.ToString(Dictionary.Variables["DateFormat"]);
Thank you.

Re: How to use variable value in method in stimulsoft

Posted: Thu Nov 22, 2012 12:09 pm
by m.issa
Hello

It is working now, really thanks a lot.

Re: How to use variable value in method in stimulsoft

Posted: Thu Nov 22, 2012 12:48 pm
by Alex K.
Hello,

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

Thank you.