TextObject tb = (TextObject )ReportDoc.ReportDefinition.ReportObjects["Text2"];
tb.Text = "订单号";
这是微软教学的一段代码,可是实际不能使用
解决方案 »
- 如何判断ooo[3].Value是否存在,又或者有更好的方法?
- 关于button的tabindex问题
- 开始学习asp.net
- 各位,问个几何的问题
- 我的Web Form突然打不开了, why???
- C#如何得到数据库中某个表的记录条数
- BindingList<T>数据源根据DataGridView自动更新的问题
- 如果在 interface 上定义 [ClassInterface(ClassInterfaceType.AutoDual)] 生成 DLL
- 程序运行过程中出错,“参数是无效的”(关于操作Bitmap)
- 如何使用C# 开发XP风格的WinForm呀!
- WCF Service 如何调用其它 WCF服务
- 第三方生产的ThinkPad笔记本外置光驱(DVD刻录机)价格?
to1 = (CrystalDecisions.CrystalReports.Engine.TextObject)ReportDoc.ReportDefinition.ReportObjects[1];
to1.Text = "xxxxxxx";
ParameterFields paramFields = new ParameterFields ();
ParameterField paramField = new ParameterField ();
ParameterDiscreteValue discreteVal = new ParameterDiscreteValue ();//--离散值
ParameterRangeValue rangeVal = new ParameterRangeValue ();//--区域值
// 假设第一个参数是具有多个值的离散参数。
// 设置参数字段的名称,它必须和报表中的参数相符。
paramField.ParameterFieldName = "客户姓名";
// 设置第一个离散值并将其传递给该参数。
discreteVal.Value = "Jeason";
paramField.CurrentValues.Add (discreteVal);
// 设置第二个离散值并将其传递给该参数。
discreteVal = new ParameterDiscreteValue ();
discreteVal.Value = "Hank";
paramField.CurrentValues.Add (discreteVal);// 将该参数添加到参数字段集合。
paramFields.Add (paramField);// 假设第二个参数为区域值。
paramField = new ParameterField ();
// 设置参数字段的名称,它必须和报表中的参数相符。
paramField.ParameterFieldName = "客户ID";
// 设置范围的开始值和结束值并将该范围传递给该参数。
rangeVal.StartValue = 10;
rangeVal.EndValue = 50;
paramField.CurrentValues.Add (rangeVal);// 将第二个参数添加到参数字段集合。
paramFields.Add (paramField);// 将参数字段集合放入查看器控件。
crystalReportViewer1.ParameterFieldInfo = paramFields;
http://www.ad0.cn/netfetch/read.php/391.htm
我把代码放在这里大家共享
if (!IsPostBack)
{
string v_bill_yearmonth = Request.QueryString["bill_yearmonth"];
string v_telecomm_account = Request.QueryString["telecomm_account"];
string connectionString =
ConfigurationManager.ConnectionStrings
["vehicleConnectionString"].ConnectionString;
string queryString =
"SELECT exchange_date,exchange_site,borrow_money,lend_money,bill_yearmonth,exchange_type FROM bill_telecomm where area='" + Session["area_code"].ToString() +
"' and telecomm_account='" + v_telecomm_account + "' and bill_yearmonth='" + v_bill_yearmonth + "' order by exchange_site,exchange_date"; DataSet ds = new DataSet(); try
{
// Connect to the database and run the query.
SqlConnection connection = new SqlConnection(connectionString);
SqlDataAdapter adapter = new SqlDataAdapter(queryString, connection); // Fill the DataSet.
adapter.Fill(ds, "bill_telecomm"); ParameterFields paraFields = new ParameterFields();
ParameterField[] paraField = new ParameterField[1];
ParameterDiscreteValue[] discreteValue = new ParameterDiscreteValue[1];
ParameterRangeValue rangeValue = new ParameterRangeValue(); paraField[0] = new ParameterField();
paraField[0].ParameterFieldName = "bank_name";
discreteValue[0] = new ParameterDiscreteValue();
discreteValue[0].Value = "工商银行";// (string)Session["Name"];
paraField[0].CurrentValues.Add(discreteValue[0]);
foreach (ParameterField pf in paraField)
{
paraFields.Add(pf);
} ReportDocument rptdoc = new ReportDocument();
rptdoc.Load(Server.MapPath("./CrystalReport1.rpt"));
rptdoc.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rptdoc;
CrystalReportViewer1.ParameterFieldInfo = paraFields;
CrystalReportViewer1.DataBind();
}
catch (Exception )
{ // The connection failed. Display an error message.
status.Text = "Unable to connect to the database."; } }
}