在不使用应用程序块的情况下,asp.net中的RDLC钻取报告 [英] RDLC drilldown report in asp.net without using application block

查看:51
本文介绍了在不使用应用程序块的情况下,asp.net中的RDLC钻取报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net 4.0中使用RDLC而不使用应用程序块的情况下,需要一个向下钻取报告的简洁示例.

Need a neat example for a drilldown report using RDLC in asp.net 4.0 without using application block.

推荐答案

步骤1:创建类型化的数据集并添加DataAdapters通过拉表或通过存储过程来访问主和子rdlc.
步骤2:设计两个RDLC Main.rdlc和Sub.rdlc
步骤3:在Sub.rdlc中创建Paramater
步骤4:在Main.rdlc中,右键单击文本框属性"列.采取行动-选择报告".在指定报告"下选择Sub.rdlc,然后添加参数,提供您在Sub.rdlc中创建的参数,然后选择要传递的数据库列值.
步骤5.创建一个Web窗体,拖动报表查看器并转到其背后的代码中的Drilldown事件,并编写如下的代码

Step 1: Create a typed Dataset and add DataAdapters for Main and Sub rdlcs by pulling table or thru Stored procedure.
Step 2: Design two RDLCs Main.rdlc and Sub.rdlc
Step 3: Create Paramater in Sub.rdlc
Step 4: in Main.rdlc, right click on the column-''Text Box Properties''. Go to Action - Choose ''Go to Report''. Choose Sub.rdlc under ''Specify a report'' then add the Parameter, give the one you created in Sub.rdlc and select the database column value to pass.
Step 5. Create a webform, drag the report viewer and go to its Drilldown event in code behind and write the code as below

protected void ReportViewer1_Drillthrough(object sender, DrillthroughEventArgs e)
        {
            
            LocalReport report = (LocalReport)e.Report;
                int MakeId = 0;
                IList<ReportParameter> list = report.OriginalParametersToDrillthrough;
                foreach (ReportParameter param in list)
                {
                    //Since i know the parameter is only one and its not a multivalue 
                    //I can directly fetch the first value from the Values array.
                    MakeId = Convert.ToInt32(param.Values[0]);
                }
                DataSets ds = new DataSets();
                ds.EnforceConstraints = false;
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Cons"].ConnectionString);
                con.Open();

                SqlCommand cmd = new SqlCommand("ModelSivaa");
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection = con;
                cmd.Parameters.AddWithValue("@MakeId", MakeId);
                cmd.ExecuteNonQuery();
                SqlDataAdapter adap = new SqlDataAdapter(cmd);
                adap.Fill(ds, "Modeltable");
                report.DataSources.Add(new ReportDataSource("ModelSet", ds.Tables["Modeltable"]));


查看下面的链接是否对您有帮助:

http://forums.asp.net/t/1648107.aspx/1 [ ^ ]

更新的答案:
http://www.dotnetyoga.com/2011/10/how- to-use-rdlc-with-aspnet.html [ ^ ]
See if below link helps you:

http://forums.asp.net/t/1648107.aspx/1[^]

Updated answer:
http://www.dotnetyoga.com/2011/10/how-to-use-rdlc-with-aspnet.html[^]


这篇关于在不使用应用程序块的情况下,asp.net中的RDLC钻取报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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