70-515 · Question #199
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">…
The correct answer is B. Dim img As Image =. See the full explanation below for the reasoning.
Question
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) 08 img.ImageUrl = 09 String.Format("images/{0}.jpg", cm.ID) 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?
Options
- ADim img As Image =
- BDim img As Image =
- CDim img As Image =
- DDim img As Image =
How the community answered
(45 responses)- A7% (3)
- B82% (37)
- C2% (1)
- D9% (4)
Community Discussion
No community discussion yet for this question.