Which code fragment should you use?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework
version 3.5.You create a FormView control to access the results of a query. The query
contains the following fields:
EmployeeID
FirstName
LastName
The user must be able to view and update the FirstName field.You need to define the control
definition for the FirstName field in the FormView control.Which code fragment should you use?

You create a Microsoft ASP.NET application by using the Microsoft .NET Framework
version 3.5.You create a FormView control to access the results of a query. The query
contains the following fields:
EmployeeID
FirstName
LastName
The user must be able to view and update the FirstName field.You need to define the control
definition for the FirstName field in the FormView control.Which code fragment should you use?

A.
<asp:TextBox ID=”EditFirstNameTextBox” RunAt=”Server” Text=”<%#
Bind(“FirstName”) %>” />

B.
<asp:TextBox ID=”EditFirstNameTextBox” RunAt=”Server” Text=”<%#
Eval(“FirstName”) %>” />

C.
<asp:TextBox ID=”EditFirstNameTextBox” RunAt=”Server” Text='<%#
Bind(“FirstName”) %>’ />

D.
<asp:TextBox ID=”EditFirstNameTextBox” RunAt=”Server” Text='<%#
Eval(“FirstName”) %>’ />

Explanation:
Since the user must be able to both view and update the FirstName field, one must use Bind rather than Eval.
In addition, since the Bind requires an argument surround by double quotes and the code must be embedded within the Html view,
single quotes must be used to surround the Text attribute rather than double quotes. Double quotes will cause a syntax error
in the Visual Studio designer.



Leave a Reply 0

Your email address will not be published. Required fields are marked *