Click here to Skip to main content
15,917,473 members
Please Sign up or sign in to vote.
3.00/5 (3 votes)
See more:

I have a button in my form .
When i click,Programatically ReportViewer should get generated,i have to bind a datasource to the report viewer and display a report to the enduser based on some constraints.

Please help me how to do this.

Thanks in Advance.

Chaithanya M
Updated 20-Jun-16 2:19am

There is an article @ Dynamic Binding Of RDLC To ReportViewer[^] just for you.
Share this answer
M.CHAITHANYA 23-May-11 2:09am    
I wanted to create a ReportViewer Dynamically and do all the later on stuff..dynamically Windows Forms
Hope this[^] might help you.
Share this answer
M.CHAITHANYA 23-May-11 2:27am    
I have the following code :

SqlConnection cn =new SqlConnection(@"Data Source=ES-SYS-692\SQL2008;Integrated Security=SSPI;Database=mydb");
DataSet ds=new DataSet();

SqlDataAdapter da=new SqlDataAdapter("select empno,ename,job from emp where sal>1250",cn);

ReportDataSource RDS=new ReportDataSource("empds",ds.Tables[0]);

ReportViewer RV = new ReportViewer();
RV.Visible = true;

LocalReport lc=RV.LocalReport;


This Code in a button click,when i click on the button..i ended up with nothing..unable to get the report(generate teh report).What has to be added to this code?
natia_21_alina_25 2-Feb-13 2:09am    
it does not work :(
Share this answer
I found the following webste after reading this post that helped me out.[^]

It is dedicated to the reportviewer in Visual Studio.

Share this answer
fjdiewornncalwe 23-Oct-12 12:26pm    
Please don't add answers on old questions like this when answers already exist. Cheers.
snorkie 23-Oct-12 13:47pm    
How would you recommend that I add additional information then? I thought this link would be useful to others...
fjdiewornncalwe 23-Oct-12 14:03pm    
It's just that the question is really old. Your link is good which is why I just left the note and didn't remove it. What happens is that when an old question is "revived" so to speak back in to the active list, we usually end up with a whole bunch of crap being added to a question that is basically in archive mode already.
snorkie 23-Oct-12 14:06pm    
Fair enough.
Hi Chaithanya check below this useful link.

ReportViewer Tutorial[^]

Using ReportViewer in WinForms C#[^]

I hope it will help you
Share this answer
Richard MacCutchan 20-Jun-16 10:17am    
Did you notice this question is over 5 years old?
CHill60 20-Jun-16 10:23am    
Did you also notice that the first link you present as a solution was included in Solution 4 over 3 years ago?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900