8.2. Enhancing Usability with LinqDataSource
The grid in the preceding section handles adding, editing, and deleting products. However, it's not friendly. In this section, you replace the supplier number with the company name to make it easier for users to add products.
8.2.1. Putting a name to a number
At runtime, the ListView you create in the preceding section shows SupplerID and CategoryID values, which are numbers. Instead of asking viewers to match the SupplierID to the company name, you can do it for them. Figure 8-2 shows that NWDataClasses.dbml includes a Supplier object with a CompanyName property. Both the company and category names are available to display in the ListView control.
Figure 8-2. The Supplier object with a CompanyName property.
Follow these steps to use the name of the supplier in the SupplierID column:
Open products.aspx in Source view.
Open the Quick Replace window (EditFind and ReplaceQuick Replace).
Set Eval("SupplierID") as the Find What text and Eval("Supplier.CompanyName") as the Replace With text in the current document.
Click Replace All.
Three occurrences are replaced.
Set Eval("CategoryID") as the Find What text and Eval("Category.CategoryName")
Get ASP.NET 3.5 For Dummies® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.