1<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="DataBindToCustomObject.WebForm1" %> 2<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 3<HTML> 4 <HEAD> 5 <title>DataBind To Custom Object</title> 6 <link type="text/css" href="layout.css" rel="Stylesheet"> 7<script LANGUAGE="JavaScript"> 8function confirm_delete() 9{ 10 return (confirm("Are you sure you want to delete this user?")) 11} 12</script> 13 </HEAD> 14 <body> 15 <form id="Form1" method="post" runat="server"> 16 <b><A href="WebForm1.aspx">Start Over</A><BR> 17 <BR> 18 Users:</b><br> 19 <asp:DataGrid id="dgUsers" runat="server" Width="600px" OnItemCommand="dgUsers_ItemCommand" AutoGenerateColumns="False" 20 CssClass="matrix"> 21 <HeaderStyle CssClass="columnO"></HeaderStyle> 22 <Columns> 23 <asp:TemplateColumn HeaderText="Email Address"> 24 <ItemStyle HorizontalAlign="Center"></ItemStyle> 25 <ItemTemplate> 26 <asp:Label ID="lblEmail" runat="server" Text='<%# ((DataBindToCustomObject.UserDetails)Container.DataItem).EmailAddress %>'> 27 </asp:Label> 28 </ItemTemplate> 29 </asp:TemplateColumn> 30 <asp:TemplateColumn HeaderText="First Name"> 31 <ItemStyle HorizontalAlign="Center"></ItemStyle> 32 <ItemTemplate> 33 <asp:Label ID="lblFirstName" runat="server" Text='<%# ((DataBindToCustomObject.UserDetails)Container.DataItem).FirstName %>'> 34 </asp:Label> 35 </ItemTemplate> 36 </asp:TemplateColumn> 37 <asp:TemplateColumn HeaderText="Last Name"> 38 <ItemStyle HorizontalAlign="Center"></ItemStyle> 39 <ItemTemplate> 40 <asp:Label ID="lblLastName" runat="server" Text='<%# ((DataBindToCustomObject.UserDetails)Container.DataItem).LastName %>'> 41 </asp:Label> 42 </ItemTemplate> 43 </asp:TemplateColumn> 44 <asp:TemplateColumn> 45 <ItemStyle HorizontalAlign="Center"></ItemStyle> 46 <ItemTemplate> 47 <asp:LinkButton ID="lnkDelete" CommandName="Delete" runat="server">Delete</asp:LinkButton> 48 </ItemTemplate> 49 </asp:TemplateColumn> 50 <asp:ButtonColumn Text="View" CommandName="View"> 51 <ItemStyle HorizontalAlign="Center"></ItemStyle> 52 </asp:ButtonColumn> 53 </Columns> 54 </asp:DataGrid> 55 <asp:Label id="lblMessage" runat="server" ForeColor="Red"></asp:Label><BR> 56 <asp:Label id="lblUserDetails" runat="server"></asp:Label> 57 </form> 58 </body> 59</HTML>