The Data Form Web Part, like its predecessor Front Page 2003, allows you to format rows of data based on conditions. You can apply formatting to rows in your data view when the data in the rows meets a certain criteria. You can also hide or show rows of data based on whether they match a particular condition. This is especially useful in situations when you need to highlight data in your presentations when certain conditions and requirements are met. This feature in SharePoint Designer is called conditional formatting.
Conditional formatting, like most of the formatting features of the Data Form Web Part, is also implemented by using the XSLT formatting. It doesn't mean to change how the data is retrieved from the data source but to apply XSLT to the data retrieved to show, hide, or apply formatting based on the conditions set. You use the familiar Filter Criteria dialog box to create conditions that when met apply the specified formatting to the matching rows of data.
You use the Conditional Formatting task pane to create conditional formatting conditions. As shown in Figure 17.35, the Conditional Formatting task pane by default shows the existing conditions that apply to the selected content on the Web page.
To create a new condition, follow these steps:
Select the HTML component on the Web page on which you want to apply the formatting based on the condition. For example, you can select the <tr> tag in the data view if you want to apply the formatting to the row or the <td> tag if you want to apply the formatting to just a column in the data view.
Click Create menu in the Conditional Formatting task pane. You have three options: Show Content, Hide Content, and Apply Formatting. The Show Content and Hide Content options show or hide the content based on the condition, while Apply Formatting lets you specify the formatting that needs to be applied to the data that needs the condition.
Click the Apply Formatting menu option. The Condition Criteria dialog box opens, offering the same interface as the Filter Criteria dialog box, which you used earlier in this chapter to create filters on the data view.
Use the Modify Style dialog box to specify the formatting that you want to apply to the rows that meet the condition specified in step 4.
Click OK, save the Web page, and then preview it in a browser.
The rows to data that matched your condition have the specified formatting applied to them. Similarly, you can use conditional formatting to show or hide content based on conditions.
13.58.115.61