ONLINEPROOFINGSITE.COM

word 2007 proofing tools - www.onlineproofingsite.com

Menu


BillingShippingAddress TextBox billshipaddress BillingShippingCity TextBox billshipcity BillingShippingState TextBox billshipstate


BillingShippingZip TextBox billshipzip Button Submit   The result of inserting all the web controls is shown in Figure 26.28. Figure 26.28. Insert all the web controls for the My Account page. [View full size image]   Recall that, when we created the ASP.NET-based New User Registration page, we had a TextBox (with the visible property set to false) for DepartmentID. Because a user won't be able to modify the department they belong to, we won't make that value available in this form. (Remember that the administrator is responsible for changing this value.) We have, however, replaced the DepartmentID TextBox with an EmployeeID TextBox. When updates are made to a database, you, as the developer, must specify which field will be updated. In Chapter 24, "A SQL Primer," we discussed the WHERE clause. The value, typically a numeric primary key, is appended to the WHERE clause so that application logic knows exactly which record in the database table to update. This numeric key is the EmployeeID. Knowing that, you'll need to switch to Code view and set the visible="false" attribute and value in the tag for the employeeid TextBox control. The result of the modification is shown in Figure 26.29. Save the page as myaccount.aspx. Figure 26.29. Add the visible="false" attribute and value to the employeeid TextBox control. [View full size image]   Binding Form Elements Now that you have the My Account form created, you will want to make all those web controls dynamic, meaning that when the page is loaded, text from the database automatically appears within them. In the previous chapter, you learned how to create dynamic text by dragging an item from the DataSet onto the page. Dynamic web controls are constructed much the same way in that you can drag an item from the DataSet directly onto the form object to which you want to bind that field. You can start binding all your web controls using the following process: 1. Create a new DataSet by selecting DataSet from the Bindings panel. When the DataSet dialog appears, enter the value dsUpdateEmployee in the Name text box. 2. Choose the connDorknozzle option from the Connection menu. 3. Select the Employees table from the Table menu. Figure 26.30 shows the formatted DataSet dialog. Figure 26.30. Enter all the appropriate information for your new DataSet. 4. Click OK. The Bindings panel lists the new DataSet along with the fields that it exposes. 5. To create a binding, simply drag each field from the DataSet (in the Bindings panel) into its corresponding web control on the My Account page. When you have all the controls bound, the result looks similar to Figure 26.31. Figure 26.31. Bind all the controls with fields from the DataSet. [View full size image] Save your work and test the results in the browser. The result should look similar to Figure 26.32. Figure 26.32. All the information in the database table for the particular user shows up in the web controls.