272Microsoft Visual Studio 2010: A Beginner’s Guide
<td>
<%= Html.Encode(item.CustomerID) %> </td>
<td>
<%= Html.Encode(item.Name) %> </td>
<td>
<%= Html.Encode(item.Age) %> </td>
<td>
<%= Html.Encode(String.Format("{0:g}", item.Birthday)) %>
</td>
<td>
<%= Html.Encode(String.Format("{0:F}", item.Income)) %>
</td>
</tr>
<% } %>
</table>
<p>
<%= Html.ActionLink("Create New", "Create") %>
</p>
</asp:Content>
Listing
For each cell being rendered, item is the current Customer and the property for that cell is referenced by the property of Customer that should display. What is particularly important about displaying the data is that each cell uses the Html.Encode helper method instead of displaying the data directly. This is a best practice for best security to ensure that any data displayed is not treated as HTML markup or accidentally runs JavaScript that you didn’t intend. You see, a malicious hacker could add JavaScript during data entry and when you display that field, the browser would try to run the JavaScript code, which