You are developing an ASP.NET Web page.
The page contains the following markup.
<asp:GridView ID=”gvModels” runat=”server”
onrowdatabound=”gvModels_RowDataBound”
AutoGenerateColumns=”false”>
<Columns>
<asp:BoundField DataField=”Name” HeaderText=”Model” />
<asp:TemplateField>
<ItemTemplate>
<asp:Image ID=”img” runat=”server” />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
The pages code-behind file includes the following code segment. (Line numbers are included for
reference only.)
01 Private Sub gvModels_RowDataBound(ByVal sender As Object, _
02 ByVal e As GridViewRowEventArgs) _
03 Handles gvModels.RowDataBound
04 If (e.Row.RowType = DataControlRowType.DataRow) Then
05 Dim cm As CarModel =
06 DirectCast(e.Row.DataItem, CarModel)
07
08 img.ImageUrl =
09 String.Format(“images/{0}.jpg”, cm.ID)
10
11 End If
12 End Sub
You need to get a reference to the Image named img. Which code segment should you add at line
07?
A.
Dim img As Image =
DirectCast(Page.FindControl(“img”), Image)
B.
Dim img As Image =
DirectCast(e.Row.FindControl(“img”), Image)
C.
Dim img As Image =
DirectCast(gvModels.FindControl(“img”), Image)
D.
Dim img As Image =
DirectCast(Page.Form.FindControl(“img”), Image)