Wednesday 16 May 2012

RDLC Basics

Basic Example Of  RDLC  (Report Definition Language Client-side)










To Understand From The Basic Let Start From Here..

            We have two tables

              1. MasterProduct

Brand
Product
ID
Brand1
Product1
101
Brand2
Product1
102
Brand3
Product2
103
Brand1
Product2
104
Brand4
Product3
105
Brand3
Product4
106
                  *ID is primary key here




       2. Transaction            
State
Quantity
ID
State1
10
101
State2
20
103
State3
40
104
State1
60
102
State2
40
101
State4
80
106
                         *Here ID is foreign key reference to ID of MasterProduct Table



Now Question is:

We want the below given output where State, Product1,2,3,4 are columns if we add product then column added and if we add state then it added to state column. It takes the quantity from Transaction and show in the rows accordingly.

And If You Have Opportunity to 

Use any of the data control of asp.net to show the output...I Suggest Use RDLC(report control of .net)

OUTPUT Will be:
State
Product1
Product2
Product3
Product4
State1
10+60=70



State2
40
20


State3

40


State4



80






use namespace...
using Microsoft.Reporting.WebForms;


Use function() Like

  public void BindReport()
    {
        SqlCommand cmd = new SqlCommand("spTest", con);
        cmd.CommandType = CommandType.StoredProcedure;
        if (con.State == ConnectionState.Closed)
            con.Open();

        DataSet ds = new DataSet();
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        adp.Fill(ds);

        ReportDataSource rds = new ReportDataSource("DataSet1_spTest", ds.Tables[0]);
      
        ReportViewer1.LocalReport.DataSources.Clear();

        ReportViewer1.LocalReport.DataSources.Add(rds);
      
        ReportViewer1.LocalReport.Refresh();
    }






But How to add change RDLC at RUN Time??

No comments:

Post a Comment

Print Only Grid View in ASP.net

ASP.net How to Print Only GridView < div id ="gridviewDiv" >   < asp:GridView ID ="gridViewToPri...