Learn how to create a Bindable Object Layer with ADO.net. The video is a step-by-step demonstration on how the process is made.


More DIY videos at 5min.com

Video Transcription

Let us close the skin file and the web config file. We are going to go ahead and take advantage of object binding an asp.net so that we can make our Ajax application data ware, right click on the project and select add new item. In this case, we are going to add a web form, change the name to product catalog, and press add. This takes us into the aspx page. Let us do a couple things here, let us set the title to be product catalog then go to design mode. For the document in the properties window let us go ahead and set the theme. Select the theme property and choose soothing, this will apply the asp.net theme to the page. The next thing we need to do is add a data set to store the data, right click on your project and select add new item, select data set. Let us give it a name and we call it products. In this example, we are going to be connecting to the adventure work simple database. We will connect to the products table and then filtrate using categories. So what we will do is add a products data set to represent our schema. Press the add button, visual studio will prompt you and ask you whether you want to save the data set into the up code directory. By storing our data set in the up code directory, we can guaranty that the raw source code for the data set will be safely protected when the solution is finally deployed. It is a good idea to store all rock code and resources in the up code directory, press yes. This will launch the table adaptor wizard. We had preconfigured a connection to the adventure work database. Press next, press next again, we are going to use equal statement so press next. We will use the query builder to add the product, product category and product sub-category tables. Press the query builder button and select the product’s table, click add. Select the product category table, press add and lastly the products sub-category table and press add, close the add table dialog. Now that we have our tables added, we need to select columns, and the product table, select the product ID, name, color and less price. For the product category table, select name and the sequel statement instead of using expression one as the alias, give it a proper name, let us call it category name. We will do the same with the sub-category table. Select the name and for the expression, we will type in subcategory name. Click okay, because our control will receive data form another control via user interaction, we will need to add a ware clause. We are going to say where products sub-category ID equals the parameter that we passed in. Let us go ahead and grab the products sub-category ID, copy that into memory and at the end of your statement type in where, paste in your product sub-category ID, equals at sub-category ID. Now, close the parenthesis, select next. We do not need a fill so uncheck that and then for the get data let us rename that is something more meaningful. Get products by sub-category ID. Select next and press finish. We can preview our data by right clicking on it and selecting preview data. It prompts us for our parameter let us type in 21, press the preview button. As you can see, we only get the sub-category jerseys for the products in our database. Press close now let us add another method to the table adopter. This method that we add get colorful product we will be using later as a web service, right click say add query again use equal statements, press next, press next again. In this case, we are going to simplify the default query. We only want to return the single value, product color. So let us delete all the other fields besides product color from our select statement. We also need modify the ware clause to accept the product ID by passing in the product ID, and we will return the product color. And then we will change the parameter name to something more meaningful. Press the next button, in this case we are getting a scale or value meaning a single value. So we get rid of to get, let us rename this to fill color for a product. Select next, when you click finish you will get a warning that indicates