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 protected void gvModels_RowDataBound(object sender, GridViewRowEventArgs e)
02 {
03 if (e.Row.RowType == DataControlRowType.DataRow)
04 {
05 CarModel cm = (CarModel)e.Row.DataItem;
06
07 img.ImageUrl = String.Format(“images/{0}.jpg”, cm.ID);
08
09 }
10 }
You need to get a reference to the Image named img.
Which code segment should you add at line 06?
A.
Image img = (Image)Page.FindControl(“img”);
B.
Image img = (Image)e.Row.FindControl(“img”);
C.
Image img = (Image)gvModels.FindControl(“img”);
D.
Image img = (Image)Page.Form.FindControl(“img”);