Exam 70-562 : Microsoft .NET Framework 3.5, ASP.NET Application Development – 18

Question: You work as an application developer at Company.com. You make use of .NET Framework 3.5 to create an ASP.NET application. You application contains a Web page named Display.aspx. Display.aspx contains a LinqDataSource DataSource named Lds1 that has a primary key named ContID and a DetailsView control that is named dv1. The code below is included in the Display.aspx file.

<asp:DetailsView ID="dv1" runat="server" DataSourceID="Lds1" />
<Fields>
<asp:BoundField DataField="ContID" HeaderText="No" InsertVisible="False" ReadOnly="True" SortExpression="ContID" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Cat" HeaderText="Category" SortExpression="Cat" />
<asp:CommandField ShowDeleteButton="false" ShowEditButton="True" ShowInsertButton="True" />
</Fields>
</asp:DetailsView>

When a user accesses the dv1 DetailsView control they must be able to insert and update content. However, you don’t want the link button controls for the Edit and Insert functions to be duplicated. You thus need to alter the DetailsView declaration. What should you do?

  1. You should consider inserting:
    AllowPaging=”true” AutoGenerateRows=”false” DataKeyNames=”ContID”
  2. You should consider inserting:
    AllowPaging=”false” AutoGenerateRows=”false”
  3. You should consider inserting:
    AllowPaging=”true” AutoGenerateDeleteButton=”false” AutoGenerateEditButton=”true”
    AutoGenerateInsertButton=”true” AutoGenerateRows=”false”
  4. You should consider inserting:
    AllowPaging=”false” AutoGenerateDeleteButton=”false”
    AutoGenerateEditButton=”true” AutoGenerateInsertButton=”true”
    AutoGenerateRows=”false” DataKeyNames=”ContID”

Correct Answer: 1


Question: You work as an application developer at Company.com. The previous developer created an ASP.NET application that uses Microsoft .NET Framework 3.5. You create a Web form with the following code in the code-behind file:
1 Dim qString As String = “select * from Orders; select * from Customers”
2 Dim cmd As New SqlCommand(qString, con)
3 con.Open()
4 Dim readr As SqlDataReader = cmd.ExecuteReader()
5
6 readr.Close()
7 con.Close()
You receive an instruction from management to make sure that information displayed in the GridView controls named gvOrders and gvCustomers are included in the Orders database table as well as the Categories database table. You thus need to determine the appropriate code that should be inserted at line 5. What should you do?

  1. You should consider inserting:
    gvOrders.DataSource = readr
    gvCustomers.DataSource = readr
    gvOrders.DataBind()
    gvCustomers.DataBind()
  2. You should consider inserting:
    gvOrders.DataSource = readr
    gvOrders.DataBind()
    gvCustomers.DataSource = readr
    gvCustomers.DataBind()
  3. You should consider inserting:
    gvOrders.DataSource = readr
    gvCustomers.DataSource = readr
    gvOrders.DataBind()
    readr.NextResult()
    gvCustomers.DataBind()
  4. You should consider inserting:
    gvOrders.DataSource = readr
    readr.NextResult()
    gvCustomers.DataSource = readr
    gvOrders.DataBind()
    gvCustomers.DataBind()

Correct Answer: 3


Question: You work as a Web Application Developer. You are currently creating a Microsoft ASP.NET application. You receive an instruction to add a custom parameter in the SqlDataSource control. You then decide to write the code segment below:

<asp:SqlDataSource ID="ds1" runat="server" InsertCommand="INSERT INTO [Orders] ([Name], [Addr], [PostedDate]) VALUES (@Name, @Addr, @PostedDate)">
<InsertParameters>
<asp:Parameter Name="Name" />
<asp:Parameter Name="Addr" />
<custom:DayParameter?Name="PostedDate" />
</InsertParameters>
</asp:SqlDataSource> 

You then create a custom parameter class using the code below:

Public Class DayParameter
Inherits Parameter
End Class 

Management wants you to make sure that the present date and time is returned by the custom parameter. You thus need to determine the appropriate code you have to add to the DayParameter class. What should you do?

  1. You should consider adding:
    Protected Overloads Overrides Function Evaluate(ByVal context As HttpContext, _
    ByVal control As Control) As Object
    Return DateTime.Now
    End Function
  2. You should consider adding:
    Protected Overloads Overrides Sub LoadViewState(ByVal savedState As Object)
    DirectCast(savedState, StateBag).Add(“Value”, DateTime.Now)
    End Sub
  3. You should consider adding:
    Protected Overloads Overrides Function Clone() As Parameter
    Dim pm As Parameter = New DayParameter()
    pm.DefaultValue = DateTime.Now
    Return pm
    End Function
  4. You should consider adding:
    Protected Sub New()
    MyBase.New(“Value”, TypeCode.DateTime, DateTime.Now.ToString())
    End Sub

Correct Answer: 1


Question: You work as a Web Developer at Company.com. You are in the process of creating a Web application that uses Microsoft ASP.NET 3.5. The application contains a page named Exams.aspx. Exams.aspx calls the following SQL query in order to display names of exams in a GridView control:

SELECT ExamID, Name, Code FROM Exams 

Another page named ExamInfo.aspx makes use of the Exam query string parameter in order to display information about an exam. The exam is identified by the ExamID field that is returned from the SQL query, the name of the book is represented by the Name field returned from the query, and the exam code is represented by the Code field. You add a HyperLink control to a template field of the GridView control. You decide to declare the HyperLink control in order for it to display exams names. It should also link the user to ExamInfo.aspx in order to view the selected book. How should you implement this Hyperlink?

  1. You need to use the declaration:
    <asp:HyperLink Text='<% Eval(“Name”) %>’
    NavigateUrl='<% Eval(“Code”, “ExamInfo.aspx?Exam=Code”)%>’/>
  2. You need to use the declaration:
    <asp:HyperLink Text='<%# Eval(“Name”) %>’
    NavigateUrl='<%# Eval(“Code”, “ExamInfo.aspx?Exam={0}”)%>’/>
  3. You need to use the declaration:
    <asp:HyperLink Text='<% Eval(“Name”) %>’
    NavigateUrl='<% Eval(“ExamInfo.aspx?Exam=Code”)%>’/>
  4. You need to use the declaration:
    <asp:HyperLink Text='<%# Eval(“Name”) %>’
    NavigateUrl='<%# Eval(“ExamInfo.aspx?Exam=Code”)%>’/>

Correct Answer: 2


Question: You work as a Web Developer at Company.com. You are in the process of creating a Web application that uses Microsoft ASP.NET 3.5. The following code exists on the application:

public class Customer
{
public string Name {get; set;}
public Address Address {get; set;}
}
public class Address
{
public string City {get; set;}
public string State {get; set;}
public string Zip {get; set;}
} 

You define a GridView control as follows and bind it to a collection of Customer instances:

<asp:GridView ID="_gridView" runat="server">
</asp:GridView> 

You need to ensure that the City property of the Address class as well as the Name property of the Customer class is displayed in separate columns. Identify the declaration that will accomplish this?

  1. You should identify:
    <asp:GridView ID=”_gridView” runat=”server” AutoGenerateColumns=”false”>
    <Columns>
    <asp:BoundField HeaderText=”City” DataField=”Customer.Address.City”/>
    <asp:BoundField HeaderText=”Name” DataField=”Customer.Name”/>
    </Columns>
    </asp:GridView>
  2. You should identify:
    <asp:GridView ID=”_gridView” runat=”server”>
    <Columns>
    <asp:TemplateField HeaderText=”City”>
    <ItemTemplate>
    <%#Eval(“Customer.Address.City”)%>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
  3. You should identify:
    <asp:GridView ID=”_gridView” runat=”server” AutoGenerateColumns=”false”>
    <Columns>
    <asp:BoundField HeaderText=”City” DataField=”Address.City”/>
    <asp:BoundField HeaderText=”Name” DataField=”Name”/>
    </Columns>
    </asp:GridView>
  4. You should identify:
    <asp:GridView ID=”_gridView” runat=”server”>
    <Columns>
    <asp:TemplateField HeaderText=”City”>
    <ItemTemplate>
    <%#Eval(“Address.City”)%>
    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>

Correct Answer: 4

Tagged . Bookmark the permalink.

Leave a Reply