How to use FormView in asp.net

FormView
FormView.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FormView.aspx.cs" Inherits="FormView" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>asp.net FormView: how to use</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Teal">FormView</h2>
        <asp:SqlDataSource 
            ID="SqlDataSource1"
            runat="server"
            ConnectionString="<%$ ConnectionStrings:Northwind %>"
            SelectCommand="SELECT CategoryID, CategoryName, Description FROM Categories"
            >
        </asp:SqlDataSource>
        <asp:FormView 
            ID="FormView1"
            runat="server"
            DataSourceID="SqlDataSource1"
            AllowPaging="true"
            >
            <HeaderTemplate>
                Product Category
            </HeaderTemplate>
            <ItemTemplate>
                CategoryID: <%# Eval("CategoryID") %><br />
                Category Name: <%# Eval("CategoryName") %><br />
                Description: <%# Eval("Description") %>
            </ItemTemplate>
            <PagerSettings Mode="Numeric"/>
        </asp:FormView>
    </div>
    </form>
</body>
</html>
FormView.aspx.cs

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class FormView : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!this.IsPostBack)
        {
            FormView1.HeaderStyle.BackColor = System.Drawing.Color.SeaGreen;
            FormView1.HeaderStyle.ForeColor = System.Drawing.Color.Snow;
            FormView1.HeaderStyle.Font.Bold = true;
            FormView1.PagerStyle.BackColor = System.Drawing.Color.ForestGreen;
            FormView1.PagerStyle.ForeColor = System.Drawing.Color.AliceBlue;
            FormView1.RowStyle.BackColor = System.Drawing.Color.Green;
            FormView1.RowStyle.ForeColor = System.Drawing.Color.White;
        }
    }
}
More asp.net examples