You create a Microsoft ASP.NET application by using the Microsoft .NET Framework version 3.5.
You create a Web page that contains the following two XML fragments. (Line numbers are included for reference only.)
01 <script runat=”server”>
02
03 </script>
04 <asp:ListView ID=”ListView1″ runat=”server”
05 DataSourceID=”SqlDataSource1″
06
07 >
08 <ItemTemplate>
09 <td>
10 <asp:Label ID=”LineTotalLabel” runat=”server”
11 Text='<%# Eval(“LineTotal”) %>’ />
12 </td>
13 </ItemTemplate>
The SqlDataSource1 object retrieves the data from a Microsoft SQL Server 2005 database table. The database table has a column named LineTotal.
You need to ensure that when the size of the LineTotal column value is greater than seven characters, the column is displayed in red color.
What should you do?
A.
Insert the following code segment at line 06. OnItemDataBound=”FmtClr”
Insert the following code segment at line 02. protected void FmtClr(object sender, ListViewItemEventArgs e){ Label LineTotal = (Label) e.Item.FindControl(“LineTotalLabel”);
if ( LineTotal.Text.Length > 7) { LineTotal.ForeColor = Color.Red; } else {LineTotal.ForeColor = Color.Black; }}
B.
Insert the following code segment at line 06. OnItemDataBound=”FmtClr”
Insert the following code segment at line 02. protected void FmtClr(object sender, ListViewItemEventArgs e){ Label LineTotal = (Label) e.Item.FindControl(“LineTotal”);
if ( LineTotal.Text.Length > 7) {LineTotal.ForeColor = Color.Red; } else {LineTotal.ForeColor = Color.Black; } }
C.
Insert the following code segment at line 06. OnDataBinding=”FmtClr”
Insert the following code segment at line 02. protected void FmtClr(object sender, EventArgs e){ Label LineTotal = new Label(); LineTotal.ID = “LineTotal”;
if ( LineTotal.Text.Length > 7) {LineTotal.ForeColor = Color.Red; } else { LineTotal.ForeColor = Color.Black; }}
D.
Insert the following code segment at line 06. OnDataBound=”FmtClr”
Insert the following code segment at line 02. protected void FmtClr(object sender, EventArgs e){ Label LineTotal = new Label(); LineTotal.ID = “LineTotalLabel”;
if ( LineTotal.Text.Length > 7) {LineTotal.ForeColor = Color.Red; } else {LineTotal.ForeColor = Color.Black; }}