C# .NET - how to pass values from dropdownlist to crystal reprt?

Asked By mani on 28-Mar-12 04:04 AM
hi..i have fom in which i am shortlisting data using between date..and also result will be taken in crystal report..all things ar ok exept that i am not able to show that shorlisted date in my repory..
how to pass this data value from dropdownlist and show it in crystal report anu helkp??
kalpana aparnathi replied to mani on 28-Mar-12 04:18 AM
hi,

For Pass the parameter values from the drop down list to the report do like this.

string rpt = DropDownList1.SelectedValue;

rpt.SetParameterValue("ReportTitle", rpt);

ParameterDiscreteValue val = new ParameterDiscreteValue();
val.Value = rpt;

ParameterValues pvalue = new ParameterValues();

pvalue.Add(val);

rpt.ParameterFields["ReportTitle"].CurrentValues = pvalue;

rpt.DataDefinition.ParameterFields[0].ApplyCurrentValues(pvalue);


Regards,
Somesh Yadav replied to mani on 28-Mar-12 08:32 AM
Hi,
 
But you didn't mention is it formula field or parameter field, but i give both snippets
 
Formula field


string strFormula ="";
 
strFormula = "{tblTable.fldField}='" + txtParam.text + "'";
 
report.DataDefinition.RecordSelectionFormula = strFormula;

Parameter field


string strParameter ="";
 
strParameter = txtCompanyName.Text;
 
report.SetParameterValue("Company", strParameter);

 
please let me know if you solved your issue.http://msdn.microsoft.com/en-us/magazine/cc301570.aspx