i have the textboxes say txtfromdate and txttodate these to textboxes are on front end forms(no db connection) and
i want to get these text box values as it is on crystal reports header section how to get it please help
i have written code:
i created the formula
repexamdesc.DataDefinition.FormulaFields["fromdate"].Text = "" + txtfromdate.Text + "";
repexamdesc.DataDefinition.FormulaFields["todate"].Text = "" + txttodate.Text + "";
where
repexamdesc=reportobject
fromdate=formula field
todate=formula field
this gives me answer in int fomat i.e if my fromdate textbox value is 6/1/2012 then
it shows output as = 6
it dosent take '/' since my formula fields(fromdate,todate) have data type int 16
how to its value to varchar
please help
any other solution will be greatly appreciated.
sameer gadadePosted Jul 26, 2012, 2:19 AM
could you help me out
here i a m giving my reportbtn click event
protected void btnReport_Click(object sender, EventArgs e)
{
dbFactory = new DBFactory();
dbConn =connection string;
dbConn.Open();
classid = 0;
dostudentmonthlyattendance = new DOStudentMonthlyAttendance();
bllstudentmonthlyattendance = new BLLStudentMonthlyAttendance();
dalstudentclass = new DALADDStudentClass();
Reportstudentmonthattendance repexp = new Reportstudentmonthattendance();
DataSet objds = new DataSet();
DataView objdw;
ReportDocument objrep = new ReportDocument();
try
{
if (!((txtlastname.Text.Equals("")&&txtfirstname.Text.Equals(""))&&(txtstartdate.Text.Equals("") && txtenddate.Text.Equals(""))))
{
classid = dalstudentclass.SelectStudentClassID(ClassName.Value, dbFactory);
DataSet ds = new DataSet();
bllstudentmonthlyattendance = new BLLStudentMonthlyAttendance();
dostudentmonthlyattendance = new DOStudentMonthlyAttendance();
SqlDataAdapter da = new SqlDataAdapter();
assignvalue();
objds = bllstudentmonthlyattendance.SelectStudent(dostudentmonthlyattendance);
if (objds != null && objds.Tables[0].Rows.Count > 0)
{
objdw = new DataView(objds.Tables[0]);
repexp.SetDataSource(objdw);
CrystalReportStudentattendance.ReportSource = repexp;
}
else
{
objdw = new DataView(objds.Tables[0]);
repexp.SetDataSource(objdw);
CrystalReportStudentattendance.ReportSource = repexp;
}
}
repexp.Refresh();
}
catch (NullReferenceException ex)
{
exLog = new LogException();
exLog.SaveException(Request.Cookies["UserName"].Value.ToString(), "FrmReportFormSubmission", "GetData", ex.Message);
Response.Redirect("FrmLogin.aspx", true);
}
catch (Exception ex)
{
exLog = new LogException();
exLog.SaveException(Request.Cookies["UserName"].Value.ToString(), "FrmReportFormSubmission", "GetData", ex.Message);
}
finally
{
if (dbConn.State == ConnectionState.Open)
{
dbConn.Close();
}
}
}
in this i just want to print textbox values i had tried your solution but unable to get answer could you help me out.
Sudhakar ChaudharyPosted Jul 20, 2012, 3:09 PM
rpt.Section1.SectionFormat.BackgroundColor = Color.AliceBlue;
//**************using parameter**********************
rpt.SetParameterValue(0, textBox1.Text);
rpt.SetParameterValue(1, textBox2.Text);
//***************************************************
//**************without parameter**********************
foreach (ReportObject rptObject in rpt.Section1.ReportObjects)
{
TextObject fld;
if (rptObject.Name.ToString() == "Text1")
{
fld = (TextObject)rptObject;
fld.Color = Color.Cyan;
fld.Border.BackgroundColor = Color.DarkGreen;
fld.Text = textBox1.Text;
}
if (rptObject.Name.ToString() == "Text2")
{
fld = (TextObject)rptObject;
fld.Color = Color.Cyan;
fld.Border.BackgroundColor = Color.DarkGreen;
fld.Text = textBox2.Text;
}
}
//********************************************************
crystalReportViewer1.ReportSource = rpt;