Using a Custom Object with ReportViewer in an ASP.Net Project - asp.net

I am trying to follow the instructions here:
http://msdn.microsoft.com/en-us/library/ms251692(v=vs.110).aspx
However, my project is an MVC project, so I can't follow the steps exactly.
I am trying to use a custom object to provide data to a local ReportViewer report. I am converting a server-side report to local (rdl => rdlc). The report viewer control already works with the server report.
In the Dataset Properties page, in the Data source box, select global.
When I try to add a dataset, I get a dialog box asking for me to choose a data connection. If I cancel out of that, I am at the Dataset Properties page, but the data source drop down is empty. Using the Report Wizard takes me essentially down the same path.
I created a new WPF project to see if I had the same problems, and it worked pretty easily. It immediately gave me data source choices of database, object, service, and sharepoint. I realize the two controls (web and windows) are completely independent.
What am I missing? Is it even possible to use the ReportViewer in an MVC project (that also has aspx pages) and use a custom object to supply data?

For whatever reason, I was able to get this to work as expected by moving the rdlc file out of the web project and into a class library.

When you use the reportviewer control in local mode, you have to obtain the data manually through your code, not using the report designer. After that, you pass it to the ReportViewer as ReportDataSource objects. They have DataTable properties which is the actually data. You obtain datatables from the db, so this is pretty straightforward.
This article explains how this is achieved.

Related

Embed WinForms in ASP.NET application

I need to make an upload application. ASP.NET already has an UploadFile control. But there is one more requirement: to be able to select a folder and to upload all his content. So I need to create an FolderBrowse control to be able to select a folder. Becase the SelectFile dialog that is included in UploadFile control looks so professional the DirectoryBrowse should look the same. I google it and found 2 solution: 1. to create in windows form a control that opena a file and opens a folder and gives the consumer the selected path.... and 2. it was something with using interop to be able to use a .net folderBrowse control ....not very clear to me this one that's why I tried to create an windows forms control and embed it in web site. The problem is:
1.
In designer I got an text over the control : The control type was not specified or the specified type could not be found.
in browser I see a little rectangle where the control should be.
If I add type = application then in browser I see nothing at all.
In win forms control I set for the user control:
[ComVisible(true)]
Can someone give me a clue please? what I am doing wrong? Or maybe another solution?

Update data in a WebForm

I'm new in developing ASP.NET WebForms application. I have an application that works on WinForms.
My main WinForm contains a control that after establishing a connection to a remote server, it receives values to visualise in the property Text of some labels in the Form. This control works in the same way in Running Mode and in Design mode as well (I'm using VS2010).
I need to have the same control that works in WebForms. I re-writed the control for working in WebForms. I obtained the same behaviour that I had in WinForms but I'm not able to update/refresh the labels with new data on display. Where am I doing wrong? Why can't I see the changes on the display in both cases?
Any help will be welcome, thank you in advance.
im not clear, which control you bind with, for example if you bind it with gridview you need to call DataBind() method after add/edit, or redirect page to load with fresh data

Using Data Source configuration wizard vs manually configuring data source

Back in the days of VB 4 / VB 5, using data bound controls and data connection wizards would add alot of overhead to the application.
I wanted to know if using the "Configure Data Source" wizard in ASP.Net 3.5 adds alot of unneeded overhead to the webpage?
Thanks
No, it doesn't. Adding the control to the page modifies your designer class code by one line (declaring the object). The wizard simply modifies your markup to include all the necessary properties and attributes that you specify.
This is easily verified by just viewing the changes that adding and configuring a datasource control makes to your page and your designer class.
Nothing the wizard does would be any different than what you would do by declaring the control programatically in your code. It's just a convenient GUI way of quickly generating your declarative markup.

Linking an ASP.NET web page to another project's code file

I have a series of .NET 2.0 web pojects that have identicle code behind in their web pages. The only thing that is different is how the html is laid out.
Is there a way that I can have a main web project that holds all the code behind (including control events like button click) and so that the other web projects reference the web page code file to this project's code files?
Edit: Note that the changes in html include exclution of certain controls, I am catoring for this by using the FindControl method so that if the control doesnt exists, I would simply have a null value.
You may try putting all the code-behind classes into a library and inheriting from a common base-class.
You can take a look at "Skin File" file type of Visual Studio. On the other hand you can learn if it works for you from the address below: http://msdn.microsoft.com/en-us/library/ykzx33wh(VS.80).aspx

How to make usercontrol available to multiple projects?

I have a set of UserControls in a ASP.NET website that I would like to share to multiple website. But it seems we are unable to create a class library with UserControls in it with the ascx file. While MSDN suggest building a Web Control, I Would rather find a way to share the existent controls instead of destroying them to create new web controls.
Is there any way of creating a library of UserControls?
Thanks
Here is one way of doing it:
Creating and Using User Control Libraries.
You can't compile them into a project per se. You can get something close to this by linking the files into the project so there is one master version of the file but each project also has its own copy. You can either:
Using a source control share function to have one location and share it into the other projects
Create one project for the controls and then link them into other project by using "Add Existing Item", clicking the little arrow next to the Add button, and selecting "Add As Link".
You should use instead a Composite control. Here is a comparison between web user controls and composite controls:
http://msdn.microsoft.com/en-us/library/aa719735(VS.71).aspx

Resources