Presenter:Todd Miranda
While Expression Web provides terrific tools for creating static html sites, rarely do we create a web site that does not have some dynamic elements. Displaying database data is accomplished by "binding" that data to controls in an ASP.NET page. This video demonstrates how to bind controls to data from a database using the tools in Expression Web.
The following text is a software generated transcript of the video. Click on a minute link to jump to a location within the video
Minute 0
Of what is taught Miranda in this video to demonstrate how the data bind controls in Mark self expression without Sosa did in an expression web by creating a new website to accuse if the website and what it would add our own pages and will call this one a more site opened so there s her site created the first ever wanted to read data bind controls is witty today that divided to so let s create a new folder and were called as folder and data and then you go to the file menu and choose import them to import a file so add a file to your project and I m tough databases that created already this database really just contains the pubs database familiar with that
Minute 1
The SQL express database file that contains the pubs database will really use that for data binding in our website okay so we had our database under our ab data folder or website for singly to do now is create an actual ASP net page will just leave it the default name default SPX and will double click that to open it and we re working split view here so if you are familiar with split view down here the bottom you can go to surely design view purely code view or you can do a split view and what the benefits of split view all their many benefits of split view of the benefits is the capability to seeing what you re doing both in design view and code view so notice that if you highlight an element in design view that same element is highlighted in code view is a great way to if you re if you re used to working with trademark you can do that here if you re used
Minute 2
To design a just a designer when we decided to do that here illustrated as you make a change in one place of the other you can see it reflected in the any other location so if you re if you re not familiar with just the markup is a great way to learn the markup when you click and drag controls so we ll be using split the union had to watch the code changes as we work in the desire so let s go over to our toolbox in our toolbox pane and NRA s feet on a control to expand that if it s not already expanded and expanded the data controls are part of that Edward and a SQL data source for first thing we do is add a data source for project that has a connection backdoor database tool at a SQL data source is a click and drag that directly into our page and noticed that would put it inside the forms element and an ASP net applications privilege
Minute 3
Of your dynamic themes or your dynamic controls need to be inside your form control reform tired so there s a data source know when you create a control in the design view certain controls have what we call these helpers and it s a small box located in the upper right hand corner if you click on that it brings up we call common tasks dialogue or common tasks from down in this isn t a dialogue We are weak in excess of the most commonly referenced accident and accomplish a common tasks for the figure controls to choose configure data source and would accuse the data source of the connection noted on any connections to run else will do new connection and wording is a SQL Server database file this is the SQL express file now if you are just using SQL Server you can select SQL Server and you can connect to SQL 2000 or
Minute 4
Thousand five SQL Server were to use express database file and will make sure that the net framework data providers selected will choose okay okay don t accuse the Browns to browse to our file in our ab data folder fears are database tool selector database file we use Windows authentication and that we can test the connection with a few changes that we need to take a look at source quickly advanced button in the properties that normally if you only have one instance of SQL Server or to SQL express installed in your machine your data source which is effectively your server name will be SQL express just like this I have multiple instances of SQL Server so I ve named this instance SQL 2005 song that is the way to SQL 2005 incidents of my server to
Minute 5
Use as a data source able to want to turn off the user incidents and we select okay that we can test the connection and we see that this connection succeeded so with these settings we were able to connect store database so that s good if you want you can draw down here you can see the connection string for the database if you d like to look at that so accused next and where to save this connection string we created connected or database listening to the default name of test connection string and why yes it is connection broke a nail what this does is it interrogates all tables that are in that figure database allows you to select the table he won t pull data from or you can just simply do a custom SQL statement and if you do a Christmas who favor you can pull from into tables to a poll from we re going to
Minute 6
To a specified column from a table or view it will just use the authors table and we did it at a real list all the columns here from that particular table and will select the columns that we want to retrieve their lower into his work in a bind some data to a drop down control in ASP net page so what we want to do is we want to grab the author ID and the author last name from the table and it is here we can have with your calls order by clause is a good advanced which actually generates some statements for us and we don t want to generate insert a big delete statements were to read the data from a database for us ago right back this particular data to our database and notice here you can only return unique rows if you need the option said will to select that your sequels that will be built here she can look here to confirm that the select statement is actually made was to
Minute 7
Click next analyst says the query just make sure you were getting the data back we expected and we are terrific solicited finish so that we configured a data source that we can use this in our ASP net page 1 thing to note is over here when we go to war data source Library pane and select the data source Library tab failure under ASP net connections we see the connection string that we stored which is the connection string bags that figure database and we also see the web config file was created for us which stores that particular connection string for double click on the web config we can see the configuration section with the connection string and are connected string is stored in order config that will be easy use it again if we need to use it again with another data source okay so lets the outdoor toolbox and
Minute 8
In that regard database we set up or data source connection for database we ve been able to pull the data out of the database that we want to bind and that we need a control to bind the data to so let s expand our standard controls section is live down here for the drop down list there is so let s take that it was dragged out on tour for so here s our drop down list added to her form element and noticed we get our common tasks here if it doesn t automatically popout you can click the common tasks and Opera but right here in the first thing we do is choose a data source for this to the data source that we want to bind to and the SQL data source one is a data source we created a few moments ago now select the data field to display in the guard a list this is the field that will likely be displayed to the user as items in the Drago list and we won t be over
Minute 9
Last name to be displayed there however we can use a different field for the value of the drop down list to whichever item is selected this is the value that will be used to identify the particular selected item and Rooney use the ID of the offer chose been okay so at this point we ve bound our data and we can t take a look at the data right now so let s save the work that we ve done will right click our default aspx and we ll preview in browser our development server to start it up for us and our browser loads and now you can see that we ve got a drop down list that are broader with the last names of our office right list at least in the right direction however in ASP net when we select a user for more for drop down menu we want to show some detail
Minute 10
Later this is a very typical scenario if net the first thing we want to do is what they ll be the drop down box that we want to get to post back to the server or anytime the selection changes so we can select the enable auto pushback checkbox in our common tasks for our drop down and that will enable our post back so that every time we change the selection of the drop down box we post back to the server through a post back to the server will we really want to do is show some detailed data when we select particular item from our drop down list so today that want to go down to our data controls and delay details of view control from just dragged that right on tour form here it will locate them beneath the drop down list she can see if we close our helper disconnect with God the our drug a list here with our detail here with
Minute 11
To go up to our HTML view if you want and we could put a paragraph tag in here so that we can add some space between the drawdown and video the detail view okay well we want to open up our common tasks for a garden view and will accuse a data source they ll will as to detail information not just a last name in the ID so we want to create a new data sources can include some additional information will choose a database data source can what s go with the default SQL data source to we already have a connection string to the database which is the same executives and strengthen the connection string is not what pulls the data in the connection string is just what makes a connection to the database so will select our existing test connection string connection and now we re specified our
Minute 12
Lengthened again and were accused from the authors table again obviously and we want to pull all of our fields actually we won t pull contrary to what we will pull ID were to make them not visible when we actually look at our particular formula but later however this time we want to choose a where clause for our SQL statement and we want to user criteria based on the selection of the drawdown listlessly and we do that was clicked to wear button and were accused the column that we want to use as our criteria to say where the author ID is equal to end this horse is going to be a control any control what we select control get parameter property shall overhear the control ID is the IDE or drop down list which we just left the drop down list one
Minute 13
And we can specify default value here if we wanted to a senior in the SQL expression where a UID forever this past and a UID and that s coming from the selected value of or drop down list and four happy with that we select add so that we and our where clause to choose okay wife of the completed selects that that s not expecting a parameter in the parameter we pass from our control is used next it was just a query in a testimony to pass the idea here is to Mono IDE so if we get are some simple information you say we don t get any values back but we are icy querying the database shows to finish writing using a lot of information is created for us appear in code view and doubt here you see that we get all the fields we were pulling back and in some demonstrations are used to
Minute 14
Solicitor s autoformat first and will to some kind of a Google for a day to give such as cuddly a style for our control is a benefit we want to do is we won t go into the width for control swing over your tag properties to it and were discussed at that with a clear the value of their original I as we walked as just a note to specify with resort to expand to accept all of our data specialist over your tour and details tasks for details view really go into any fields and here s where we can modify the fields that were using soap and click on each field for us is the a UID within change its header text and we can also change weather is visible but all of a sudden want the ID to show up on a particular page will set the visible false will go to the last name field governor said its header to
Minute 15
Last name and maybe put after it and they will go to the other fields and with same thing first name and will just change this to be a capital P to make it look like the others and same for address may be even for dreadful call this street address and we ll see regards if so will change that deserve after it and study in the same for it and city open so chase the headers for up to airfields at its other properties that we can set in here s will that affect how this is laid out we can change the spirals of the header footer and item we can use that other properties here to affect
Minute 16
How these particular columns are reviewed okay so once we ve done that we ve nail tight this to another data source we specify the data source needs to key off of the fact that were merely changing values in our drop down list and let s run this and see how this works will say first and will preview in browser severely or with our drop down list that we have seen before with our authors populated as we change our offer we get a post back to the server and our details view runs the query using the input value of the ID of the author that we selected pulls back the default data for the author and we bailed it to this details view control disbelief at the this is how you can do a child after child type for more apparent to all platform
Minute 17
To view the detail information based on entry selected by the user and we have to write any code we changed a few properties and drag and drop for controls and much everything was done very simply ever are rapidly very easy to do this in Marshall s expression web
Click here to go to original video page
Tuesday, July 8, 2008
Video: DATABIND CONTROLS IN EXPRESSION WEB
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment