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 Sub FmtClr(sender As Object, e As ListViewItemEventArgs)
Dim LineTotal As Label = DirectCast(e.Item.FindControl(“LineTotalLabel”), Label)
If LineTotal.Text.Length > 7 Then
LineTotal.ForeColor = Color.Red
Else
LineTotal.ForeColor = Color.Black
End If
End Sub
B.
Insert the following code segment at line 06.
OnItemDataBound=”FmtClr” Insert the following code segment at line 02.
Protected Sub FmtClr(sender As Object, e As ListViewItemEventArgs)
Dim LineTotal As Label = DirectCast(e.Item.FindControl(“LineTotal”), Label)
If LineTotal.Text.Length > 7 Then
LineTotal.ForeColor = Color.Red
Else
LineTotal.ForeColor = Color.Black
End If
End Sub
C.
Insert the following code segment at line 06.
OnDataBinding=”FmtClr” Insert the following code segment at line 02.
Protected Sub FmtClr(sender As Object, e As EventArgs)
Dim LineTotal As New Label()
LineTotal.ID = “LineTotal”
If LineTotal.Text.Length > 7 Then
LineTotal.ForeColor = Color.Red
Else
LineTotal.ForeColor = Color.Black
End If
End Sub
D.
Insert the following code segment at line 06.
OnDataBound=”FmtClr” Insert the following code segment at line 02.
Protected Sub FmtClr(sender As Object, e As EventArgs)
Dim LineTotal As New Label()
LineTotal.ID = “LineTotalLabel”
If LineTotal.Text.Length > 7 Then
LineTotal.ForeColor = Color.Red
Else
LineTotal.ForeColor = Color.Black
End If
End Sub