Assignment 4 part 1
Objective: Create a page that uses 2 SQL data sources: one to populate a drop-down list and another to display the data in a data list.
- Design the Customer Incident Display page with an intuitive interface.
- When the user selects a customer from the drop-down list, all the incidents for that customer are displayed in a data list.
- Create the CustomerIncidentDisplay.aspx.
- Add a SQL data source to the page.
- Create a new connection to the TechSupport_Data.mdf database.
- Save the connection in the web.config file.
- Select the CustomerID and Name columns from the Customer table and sort by Name.
- Add a Customers drop-down list and bind it to the SQL data source you just created. It should display the name and use the Customer ID as the value. Be sure to set the AutoPostback property to True since this value will be used to populate our DataList below.
- Add a second SQL data source to the page.
- Use the connection you created for the first data source
- Use the Query Builder to create the Select statement that joins data from three tables (Incidents, Technicians, and Products) and includes only the incidents for the selected customer. It should include the Product Name, Incident Title, Technician Name, Incident Description, Date Opened and Date Closed.
- Filter the data by CustomerID which should tie to the Customers drop-down list control on the Web form.
- Add a DataList to the page to display the incidents using the second SQL data source. Format the DataList any way you like.
- Test, Upload and Submit
- Test your pages to make sure they work correctly. Use the debugging and trace techniques from Lesson 2 to help you find any errors. You should be doing this anyway.
- Submit your assignment.
5. Use the AjaxControlToolkit to use expanders (or accordion controls) between sections. Implement this any way you see fit, as long as it looks good and makes sense
Assignment 4 Part 1 Hints
- Assignment 4 Example.txt (1.721 KB)
These are the long-awaited Assignment 4 hints. The good news is that this assignment can be done without any code-behind at all. However, if you’d like to use code-behind, that is an option as well.
By now, you should be fully aware that this will require 2 SqlDataSource objects: 1 to populate the DropDownList, the other to bring up the Incident details. The second one depends on the first one, and my example will illustrate this dependency.
You may not be aware of this, but you’d be well-advised to use a DataList control for the Incident details.
Look into using Eval for this. Evals allow you to bind databound controls to query results in the easiest fashion.
Take a look at the attached; this is the pattern to (sort of) follow to get this done. It’s not complete; that’s up to you, but it’s more than enough to point you in the right direction.
ASSIGNMENT 4 PART 2
This is a configuration assignment rather than a programming assignment. You are to retarget Assignment 4 to point to the TechSupport DB on your local SQL Server instance
1) If you have not already, deploy the TechSupport DB to your SQL Server Instance (should have been done in a previous exercise – see TIps & Resources -> Database Files -> TechSupport DB -> Do-It-Yourself DB Creation for a refresher).
2) Change the connection string in your Assignment 4 submission to point to the SQL Server instance rather than the .MDF file. (BIG HINT: This is located in your web.config file).
If you need help with your connection string, a great site that will serve you well now and into the future is the venerable ConnectionStrings.com. This site shows you how to connect your application to virtually any data source. Be prepared to be amazed.
The application must continue to work as always, only using the SQL Server instance and not the .MDF file.
UPDATE: If for some reason your solution does not debug properly but your connection string is confirmed as being 100% correct (ask me in an email to double check it), feel free to submit your assignment anyhow. There could be a VS configuration issue blocking your ability to debug.