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();
}
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();
}