如何仅获取垂直记录的报告(从下拉列表中选择)? [英] How to get report for perticular record only (selected from dropdownlist)?
本文介绍了如何仅获取垂直记录的报告(从下拉列表中选择)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hiii朋友...
我在按钮单击事件上编写了以下代码...相反,我获取了所有记录.我想要特定的下拉记录值作为一条记录..如果有人知道解决方案,请帮助我..
Hiii Friends...
I have written following code on my button click event...instead i m getting all records.I want perticular one record for selected value of dropdown..Help me If u guys know the solution..
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//BindGrid();
BindVoucher();
//BindDrpDown();
}
}
public void BindVoucher()
{
string str = string.Format("select VoucherNo from vw_Expense");
DataTable dt1 = db.GetDataTable(str);
DropDownList1.Items.Clear();
DropDownList1.DataSource = dt1;
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, "Select");
}
protected void Button1_Click(object sender, EventArgs e)
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(Server.MapPath("CryRpt.rpt"));
cryRpt.SetDatabaseLogon("sa", "indmxabeais", @"VISHWANATH\SQL2008", "EMS");
string sqlstr = string.Format("select VoucherNo,ExpDate,Reimbursetype,Amount,Advance,StaffName from vw_Expense where VoucherNo='" + DropDownList1.SelectedValue + "'");
DataTable dt = db.GetDataTable(sqlstr);
cryRpt.SetDataSource(dt);
CrystalReportViewer1.ReportSource = cryRpt;
CrystalReportViewer1.RefreshReport();
}
推荐答案
在选择更改时,编写代码:
on selection change, write your code code:
string sqlstr = string.Format("select VoucherNo,ExpDate,Reimbursetype,Amount,Advance,StaffName from vw_Expense where VoucherNo='" + DropDownList1.SelectedValue + "'");
DataTable dt = db.GetDataTable(sqlstr);
cryRpt.SetDataSource(dt);
CrystalReportViewer1.ReportSource = cryRpt;
CrystalReportViewer1.RefreshReport();
这篇关于如何仅获取垂直记录的报告(从下拉列表中选择)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文