This is a migrated thread and some comments may be shown as answers.

Crosstab Display value in ReportHeader Problem

0 Answers 82 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Saima Gul
Top achievements
Rank 1
Saima Gul asked on 02 Jun 2011, 07:58 AM
Hi
I have placed a Textbox in Report header section and name it prm2
i set its value in Report_NeedDatasource event but its value are not displayed when preview the report
For other non cross tab reports it works fine 

Here is my code

 private void crosstab1_NeedDataSource(object sender, EventArgs e)
        {
            SqlConnection CN = new SqlConnection();
            SqlCommand cmd = new SqlCommand();
            SqlDataAdapter adp;
            try
            {
                string strQuery = "", strWhere = "";
                //--- Criteria
                string vToDate = sftParser.NullToVal(prm["toDate"]);
                string vFromDate = sftParser.NullToVal(prm["fromDate"]);
                if (vFromDate.Equals(""))
                    vFromDate = common.registry.getOpeningDate();
                if (vToDate.Equals(""))
                    vToDate = "2050-12-12";
                 //-----------------------------------------------------------------------
                strQuery = @"Select ExternalCode,ProductName,PackingName,WareHouseId,WareHouseTitle,Type,SUM(Qty) as Qty
                    FROM         StockTransaction ST 
                    WHERE    ST.TransactionDate>=@FromDate And ST.TransactionDate<=@ToDate
                    Group by Pro.ExternalCode,Pro.ProductName,PP.PackingName,WH.WareHouseId, WH.WareHouseTitle,Type";

                cmd.CommandText = strQuery; cmd.Connection = CN;
                cmd.Parameters.AddWithValue("@FromDate", vFromDate);
                cmd.Parameters.AddWithValue("@ToDate", vToDate.Equals("") ? null : vToDate);
                
                //passing null value to parameters not supplied
                foreach (SqlParameter Parameter in cmd.Parameters)
                {
                    if (Parameter.Value == null)
                        Parameter.Value = DBNull.Value;
                }
                adp = new SqlDataAdapter(cmd);
                
                DataTable tbl = new DataTable();
                adp.Fill(tbl);
                adp.Dispose();




                Telerik.Reporting.Processing.Table table = (Telerik.Reporting.Processing.Table)sender;
                table.DataSource = tbl;
                //-------------------------------------------------------------------------
                vToDate = sftParser.NullToVal(prm["toDate"]);
                this.prm2.Value = "From: " + String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(vFromDate)) + " To: " + (vToDate.Equals("") ? " All " : String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(vToDate)));

               // or apply this did not work
 Telerik.Reporting.TextBox txt = this.Items.Find("prm2", true)[0] as Telerik.Reporting.TextBox;
                txt.Value = "From: " + String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(vFromDate)) + " To: " + (vToDate.Equals("") ? " All " : String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(vToDate)));

               
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                cmd.Dispose();
                CN.Close(); CN.Dispose();
            }
             

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Saima Gul
Top achievements
Rank 1
Share this question
or