Viewing source for recipe1308cs.aspx

<%@ Page Language="C#" Debug="True" %>
<%@ Import Namespace="System.Data" %>
<script runat="server">

void Page_Load(Object sender, EventArgs e)
{
	// Create a data source to use
	DataTable dt = new DataTable("Contacts");
	dt.Columns.Add("UserID", System.Type.GetType("System.Int32"));
	dt.Columns.Add("FirstName", System.Type.GetType("System.String"));
	dt.Columns.Add("LastName", System.Type.GetType("System.String"));
	dt.Columns.Add("PhoneNo", System.Type.GetType("System.String"));
	dt.Columns["UserID"].AutoIncrement = true;
	
	DataRow dr;

	dr = dt.NewRow();
	dr[1] = "John";
	dr[2] = "Doe";
	dr[3] = "555-555-5555";
	dt.Rows.Add(dr);
	dr = dt.NewRow();
	dr[1] = "Harry";
	dr[2] = "Smith";
	dr[3] = "555-444-4444";
	dt.Rows.Add(dr);
	dr = dt.NewRow();
	dr[1] = "Peter";
	dr[2] = "Rogers";
	dr[3] = "555-333-3333";
	dt.Rows.Add(dr);

	DataGrid1.DataSource = dt;
	DataGrid1.DataBind();
}
</script>
<form runat="server">
	<asp:DataGrid runat="server" id="DataGrid1" AutoGenerateColumns="False" ShowFooter="True">
		<Columns>
			<asp:TemplateColumn>
				<HeaderTemplate>
				Name
			</HeaderTemplate>
				<ItemTemplate>
					<asp:Label runat="server"
					Text='<%# DataBinder.Eval (Container.DataItem, "FirstName") + " " + DataBinder.Eval (Container.DataItem, "LastName") %>' />
				</ItemTemplate>
				<EditItemTemplate>
				First Name : <asp:TextBox runat="server"
						Text='<%# DataBinder.Eval (Container.DataItem, "FirstName") %>' />
				<br>
				Last Name : <asp:TextBox runat="server"
						Text='<%# DataBinder.Eval (Container.DataItem, "LastName") %>' />
			</EditItemTemplate>
				<FooterTemplate>
					<asp:HyperLink runat="server" Text="Go Home" NavigateUrl="default.aspx" />
				</FooterTemplate>
			</asp:TemplateColumn>
			<asp:BoundColumn HeaderText="Phone Number" DataField="PhoneNo" ReadOnly="False" DataFormatString="{0:N}" />
			<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Save" CancelText="Cancel" EditText="Edit" />
			<asp:ButtonColumn HeaderText="Remove Contact" ButtonType="LinkButton" Text="Remove" CommandName="RemoveContact" />
			<asp:HyperLinkColumn Text="View Contact Details" DataNavigateUrlField="UserID" DataNavigateUrlFormatString="userdetails.aspx?userid={0}" Target="_new" />
		</Columns>
	</asp:DataGrid>
</form>