当前位置:编程学习 > C#/ASP.NET >>

请教用CHECKBOX实现水晶报表的问题

XD初学C#和水晶报表,我想通过在界面上设置有站点编号,年月日,然后用CHECKBOX来选择字段

 String fldstr = "";
  
  String[] fldArr = new string[21];
  if (checkBox21.Checked == true)
      fldstr = fldstr + "," + checkBox21.Text;
  if (checkBox18.Checked == true)
      fldstr = fldstr + "," + checkBox18.Text;
  if (checkBox19.Checked == true)
      fldstr = fldstr + "," + checkBox19.Text;
  if (checkBox20.Checked == true)
      fldstr = fldstr + "," + checkBox20.Text;
  
  
  if (checkBox1.Checked == true)
      fldstr = fldstr + "," + checkBox1.Text;
  if (checkBox2.Checked == true)
      fldstr = fldstr + "," + checkBox2.Text;
  if (checkBox3.Checked == true)
      fldstr = fldstr + "," + checkBox3.Text;
  if (checkBox4.Checked == true)
      fldstr = fldstr + "," + checkBox4.Text;
  if (checkBox5.Checked == true)
      fldstr = fldstr + "," + checkBox5.Text;
  if (checkBox6.Checked == true)
      fldstr = fldstr + "," + checkBox6.Text;
  if (checkBox7.Checked == true)
      fldstr = fldstr + "," + checkBox7.Text;
  if (checkBox8.Checked == true)
      fldstr = fldstr + "," + checkBox8.Text;
  if (checkBox9.Checked == true)
      fldstr = fldstr + "," + checkBox9.Text;
  if (checkBox10.Checked == true)
      fldstr = fldstr + "," + checkBox10.Text;
  if (checkBox11.Checked == true)
      fldstr = fldstr + "," + checkBox11.Text;
  if (checkBox12.Checked == true)
      fldstr = fldstr + "," + checkBox12.Text;
  
  if (checkBox13.Checked == true)
      fldstr = fldstr + "," + checkBox13.Text;
  if (checkBox14.Checked == true)
      fldstr = fldstr + "," + checkBox14.Text;
  if (checkBox15.Checked == true)
      fldstr = fldstr + "," + checkBox15.Text;
  if (checkBox16.Checked == true)
      fldstr = fldstr + "," + checkBox16.Text;
  if (checkBox17.Checked == true)
      fldstr = fldstr + "," + checkBox17.Text;


          
         
  if (fldstr.Substring(0, 1) == ",") 
  
      fldstr = fldstr.Substring(1, fldstr.Length-1);

  fldArr = fldstr.Split(new Char[] { ',' });


  string sql = "select fldArr from voinf where (站点编号='" + TextBox1.Text + "') and  (年='" + TextBox2.Text + "') and (月='" + TextBox3.Text + "') and (日='" + TextBox4.Text + "')";
  
 
        DataSet ds = new DataSet();
        OleDbConnection mysqlcon = new OleDbConnection(@"Provider=Microsoft.Jet.OleDb.4.0;Data Source=D:\Backup\我的文档\Visual Studio 2005\WebSites\WebSite1\zhandian.mdb");
        mysqlcon.Open();
        OleDbCommand com = new OleDbCommand(sql, mysqlcon);
        OleDbDataAdapter sqlad = new OleDbDataAdapter();
        sqlad.SelectCommand = com;
        sqlad.Fill(ds, "voinf");
        mysqlcon.Close();
        string path1 = Server.MapPath("~\\reports1\\");
        string path2 = path1 + "CrystalReport.rpt";
     
      CrystalReportSource.ReportDocument.Load(path2);
        CrystalReportSource.ReportDocument.SetDataSource(ds.Tables["voinf"]);
        CrystalReportSource.DataBind();
        CrystalReportViewer.ReportSource = CrystalReportSource;
        CrystalReportViewer.DataBind();


--------------------编程问答-------------------- 帮顶哈……
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,