水晶报告分页问题 [英] crystal reports paging problem

查看:85
本文介绍了水晶报告分页问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用水晶报告如下。我将三个参数fromdate,todate和userid传递给我的查询加载水晶报告。水晶报告正确加载,查询也正确地记录了。我从后面的代码绑定报告如下:



页面加载和GenerateReport按钮点击: -

ReportDocument rptDoc = new ReportDocument();

dsSample ds = new dsSample(); //.xsd文件名

DataTable dt = new DataTable();



//只需设置数据表的名称

dt.TableName =Crystal Report;

dt = getAllData(); //这个函数位于这个函数下面

ds.Tables [0] .Merge(dt);



//你的.rpt文件路径将在下面

rptDoc.Load(Server.MapPath(CReport2.rpt));



//将数据集设置为报告查看器。

rptDoc.SetDataSource(ds);

CrystalReportViewer1.ReportSource = rptDoc;

CrystalReportViewer1.RefreshReport();



Getalldata函数包含查询



private DataTable getAllData()

{

// int Uid = Convert.ToInt32(ddlUser.SelectedValue);

//txtFrom.Text =

//txtTo.Text = Session [FrmDateRpt]。ToString(); // currentdate也可以使用

//ddlUser.SelectedValue = Session [UsrRpt]。ToString();





DataSe t ds = null;

尝试

{

//打开Sql连接

string connstr = ConfigurationManager.ConnectionStrings [ConnectionString]。ConnectionString.ToString();

SqlConnection SqlCon = new SqlConnection(connstr);

SqlCon.Open();



//创建命令

SqlCommand SqlComm = new SqlCommand();

SqlComm.Connection = SqlCon;

SqlComm.CommandType = CommandType.Text;



string query =SELECT first_name,last_name,country,Quantity FROM Table1 where convert(datetime,FromDate,101)> ; ='+ txtFrom.Text +'并转换(datetime,ToDate,101)< ='+ txtTo.Text +'和userid =+ ddlUser.SelectedValue +;





SqlComm.CommandText =查询;



ds = new DataSet();

SqlDataAdapter SqlDa = new SqlDataAdapter(SqlComm);

SqlDa.Fill(ds,DataTable1); < br $>




}

catch(例外情况)

{

抛出新的例外(ex.Message);

}

终于

{



}

返回ds.Tables [0];

}

报告显示第一页上的一些记录但是我点击下一页按钮,看到更多的记录,它显示没有记录。问题我无法理解。帮助我..

I am using crystal reports as follows.i m passing three parameters fromdate,todate and userid to my query for loading crystal report.the crystal report loads properly and the query also brings the records properly.I m binding report from code behind as follows.

on page load and GenerateReport button click :-
ReportDocument rptDoc = new ReportDocument();
dsSample ds = new dsSample(); //.xsd file name
DataTable dt = new DataTable();

// Just set the name of data table
dt.TableName = "Crystal Report";
dt = getAllData(); //This function is located below this function
ds.Tables[0].Merge(dt);

// Your .rpt file path will be below
rptDoc.Load(Server.MapPath("CReport2.rpt"));

//set dataset to the report viewer.
rptDoc.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rptDoc;
CrystalReportViewer1.RefreshReport();

Getalldata function contains the query as

private DataTable getAllData()
{
//int Uid = Convert.ToInt32(ddlUser.SelectedValue);
//txtFrom.Text =
//txtTo.Text = Session["FrmDateRpt"].ToString();//currentdate can also be used
//ddlUser.SelectedValue = Session["UsrRpt"].ToString();


DataSet ds = null;
try
{
// Open Sql Connection
string connstr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString();
SqlConnection SqlCon = new SqlConnection(connstr);
SqlCon.Open();

// Create a Command
SqlCommand SqlComm = new SqlCommand();
SqlComm.Connection = SqlCon;
SqlComm.CommandType = CommandType.Text;

string query = "SELECT first_name,last_name,country,Quantity FROM Table1 where convert(datetime,FromDate,101) >='" + txtFrom.Text + "' and convert(datetime,ToDate,101) <='" + txtTo.Text + "' and userid =" + ddlUser.SelectedValue + "" ;


SqlComm.CommandText = query;

ds = new DataSet();
SqlDataAdapter SqlDa = new SqlDataAdapter(SqlComm);
SqlDa.Fill(ds, "DataTable1");


}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
finally
{

}
return ds.Tables[0];
}
Report shows me some records on first page but when i click on next page button to see more records it dispalys no records.Whats the problem i m not able to understand.Help Me..

推荐答案

将您的代码移动到 Page_Init 活动

如何浏览水晶页面报告使用工具栏? [ ^ ]
Move your code to Page_Init event
How to navigate page in crystal report using toolbar?[^]


这篇关于水晶报告分页问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆