ASP.net MVC Integrating RDLC Report

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends today in this video we are going to demonstrate to you how to integrate our dlc report in asp.net mvc application so let's get started it's a web as a project which channel and they say rd lc demo we say mvc and this is by default and currently we're not going for authentication we say add a project so this project uses ms sql database we have a database as report demo i have a table called customers and i have some data already pre-populated which has customer id name mobile and email i also have a procedure which should be called from our application to pre-populate information we simply uh select all from customer procedure because i don't wish to write any inline query in our front-end application so this is a project which is loaded so first let's go ahead and create our customer model class we name it as customer dto uh i will just try to save the time by just copying the properties so we have all the four fields and we also go ahead and add the connection string over here when that code is ready so we just say the connection string over here so this is the connection the name of the connection string is default connection and this is connecting to our report. okay so connection string is also added now we will add the down layer customer download so this will actually connect to our database and fetch the data so we will use certain classes since we are using data dot sql client we use sql client and we are also using since we are going to fetch the connection string from a web.config we might use this configuration class okay let's also use our model class which will be required okay now let's go ahead and say public list object so we are creating a method we should return a list of customers let's see get all customers okay now first we fetch the connection string from web.context using configuration configuration duration manager connection strings and we pass in our default connection name and we say connection string so this fetch is a connection string now let's create sql connection cnn and we pass in the connections string and then we open the connection all that let's create a command object and pass in the sp customers procedure which i have and the connection let me just confirm whether the procedure name is sp customers yes it is the landlist for now i call the i data reader i guess it requires a class using starting and reader and i execute this command execute reader with default execute reader with command as default okay so now we have the connection string established we have a database connection open we have also created a command object that will call a procedure so that's why i didn't want to write any inline query over here otherwise we can also write the indian query over here and then we execute the command object and we get all the data in the reader now let's loop in and fill in the list object red okay and okay we need to create a variable to hold the customer data let's say nsd data we're creating a class object here it has all the properties defined so we say lst data dot add and there's a new customer dto and then we say customer id call it the customer id and customer name then we call in let's just do this okay and we call in mobile and then email okay so we have populated a list object and then we return that to our column sorry it's return that's it our dire class is ready now let's call this in the report so in order to add a report we just first will add a folder as reports and then we add a data set object which will customize yes so we are going to add a data table and it's calling yes data and we add the column as customer id and then we call in the customer name recording the customer name and mobile and email so our data set which is uh prepared for the report it's holding all the columns now this columns will be bind with the report so it's time to go ahead and add the report so as a new item you go to the reporting section click on report rdlc and say list of customers so this is a design view of the report where we are going to drag and drop the fields we should be displayed in the report in run time first we need to add the data center so i have just named the data set we select the dataset and we have the fields over here now since we have multiple records we will take the table object and we will find it with the fields it's as simple as that and we say you can drag it and you can format it as per your requirement and it provides a very easy tool like you can just select it format it and you will give it a color so all this is possible can you click change the header name also okay so this is a report as i've now just formatted now the last stage is where we need to hold this report in the report viewer so for that we add waveforms as report viewer and here we need to include the report viewer component which will actually hold up the report so here's a report we'll continue we just drag it and push it in the design view we also need to add the script manager so we say the script manager over here okay and then let's see how does it view it so this is what it it is visible so this is how it will look in the design view now this panel is very all your reports can be loaded here in our case we are loading the cust list of customer report which we created okay so we are going to dynamically load this list of customer in the container over here okay so let's go ahead and write the routine to load the report in the report viewer go to the report viewer and go to the form object and and just write this code over there is push back make sure you handle the post back and then you call that same data set i think so we just use this code over here so what we'll do is that we will we need to reference so let me just first take up the dto so i use this and i say lsd data and this is my opponent then i call the dal customer dial question editor set and then i say this data and underscore customer tag okay and i say get all customers so my data is populated now now i will load this report in this viewer so i need to write some code over here for the report when report your control is reported viewer one so okay so i go ahead you can name it any any but this is this default name is report your one so i say report viewer one dot local report dot report path sorry this report path and i select server map path and i select list of customers dot r dlc that's it so this loads the report now report your one dot local report dot data source not clear just in case we need to clear it and report here dot local dot data source dot add and then we say new report data source we say ds data and we call in the lst list object okay and then we say close it so this is the code this is three lines of code which we write just to load the report so we are pretty popular we are populating the information over here we are creating a data set and passing the data set over here if you want we can also add a filter over here dynamically and then load it accordingly so our report object and report is ready let's run it once let's rebuild it and let's run it once okay so so the report is getting loaded so you will have a report component over here and you will receive yes so this is how the report is loaded okay you can see and obviously since this is a inbuilt report controller you can it has many other features like you can save this report in in the pdf for word files like if you can just click on this and you can see the report over here so you don't have to write any additional code and by the way you can also dynamically generate the pdf file for using this uh rtlc report here even that facility is there so if you wish to know for me to create such videos where you can dynamically gender the report and send it on email in pdf format to let me know in the comment section and i hope you like this video please do subscribe and like the channel thank you
Info
Channel: Digital TECHJOINT
Views: 2,640
Rating: undefined out of 5
Keywords: RDLC, asp.net, mvc, asp.net mvc, rdlc report, calling procedure in asp.net mvc, learn asp.net mvc
Id: J_M1WY-gd0A
Channel Id: undefined
Length: 13min 2sec (782 seconds)
Published: Thu Mar 25 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.