c# - Printing Crystal Report in loop -
my requirement generate/print mark-sheet of student of particular class @ single click, in crystal report.
when used loop shows last record/page of report.
and code
private void btngenerate_click(object sender, eventargs e) {
try { axcrystalactivexreportviewer1.reportsource = null; reportdocument cryrpt = new reportdocument(); tablelogoninfos crtablelogoninfos = new tablelogoninfos(); tablelogoninfo crtablelogoninfo = new tablelogoninfo(); connectioninfo crconnectioninfo = new connectioninfo(); tables crtables; crconnectioninfo.servername = configuration.servername; crconnectioninfo.databasename = configuration.databasename; crconnectioninfo.userid = configuration.server_username; crconnectioninfo.password = configuration.server_password; crtables = cryrpt.database.tables; foreach (crystaldecisions.crystalreports.engine.table crtable in crtables) { crtablelogoninfo = crtable.logoninfo; crtablelogoninfo.connectioninfo = crconnectioninfo; crtable.applylogoninfo(crtablelogoninfo); } for(int i=0; i<=x; i++) { dataset ds_viewtermmarksheet = new dataset(); hashtable htviewtermmarksheet = new hashtable(); htviewtermmarksheet.add("@year", txtyear.text); htviewtermmarksheet.add("@faculty", cbofaculty.text); htviewtermmarksheet.add("@level", cboclass.text); htviewtermmarksheet.add("@section", cbosection.text); htviewtermmarksheet.add("@term", cboterm.text); htviewtermmarksheet.add("@crn",.tostring()); dboperations _dbaccess = new dboperations(); _dbaccess.selectstoredprocedure(ds_viewtermmarksheet, "spselectexamview_exam_termwisemarksheet", htviewtermmarksheet, "marks"); cryrpt.setdatasource(ds_viewtermmarksheet.tables["marks"]); } axcrystalactivexreportviewer1.refresh(); cryrpt.close(); } catch (exception ex) { messagebox.show("mark sheet generation not successful.\r" + ex.message, "error!"); } }
how can append multiple marksheet @ once , print them @ once??
your code loop , set datasource multiple times , refresh report last one. need move refresh indice loop andalso print report there:
cryrpt.setdatasource(ds_viewtermmarksheet.tables["marks"]); axcrystalactivexreportviewer1.refresh(); // print rpeort }
the right way handle create report, shows information students. can group student id or name , set new page after group. print report ( 1 time).
Comments
Post a Comment