c# - Passing Textbox value to Crystal Report textbox -
hello have problem passing textbox value textbox object in crystal report.
so far these following codes have tried:
textobject yr = (textobject)cy.reportdefinition.sections["section1"].reportobjects["gender1"]; yr.text = txtgender.text;
it prompts error message saying: index outside bounds of array.
cy.setparametervalue("gender1", txtgender.text);
this 1 prompts: invalid index
this code loading records. works except passing value of textbox.
legend:
dt1 = dataset
crpt.rpt = crystal report file
sqlconnection conn = constring.getcon(); reportdocument cy = new reportdocument(); conn.open(); cy.load(application.startuppath + @"\crpt.rpt"); textobject gr = (textobject)cy.reportdefinition.sections["section1"].reportobjects["gender1"]; gr.text = txtgender.text; sqldataadapter da = new sqldataadapter("exec viewinfo @gen", conn); da.selectcommand.parameters.addwithvalue("@gen", txtgender.text); dt1 ds = new dt1(); da.fill(ds.info); cy.setdatasource(ds); crystalreportviewer1.reportsource = cy; conn.close();
anyone?
if you're trying set parameter in report, can use
crystalreportviewer1.parameterfieldinfo["gender1"].currentvalues.add(txtgender.text)
...after setting crystalreportviewer.reportsource
, though if you're getting error, maybe have typo in parameter name or parameter wasn't created in report file (.rpt) in first place.
you reportdocument.recordselectionformula
if you're trying use txtgender.text
filter data.