DetailsView: Displays a single data item in an HTML table.
This control enables you to display, page, edit, and add data.
FormView: Uses a template to display a single data item. Unlike the DetailsView, a FormView enables you to layout a form by using templates.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<form id="form1" runat="server">
<div class="floater">
<h3>GridView</h3>
<asp:GridView
id="GridView1"
DataSourceId="srcProducts"
Runat="server" />
</div>
<div class="floater">
<h3>DataList</h3>
<asp:DataList
id="DataList1"
DataSourceId="srcProducts"
RepeatColumns="2"
Runat="server">
<ItemTemplate>
<%#Eval("Title")%>
<i>directed by</i>
<%#Eval("Director")%>
</ItemTemplate>
</asp:DataList>
</div>
<div class="floater">
<h3>DetailsView</h3>
<asp:DetailsView
id="DetailsView1"
DataSourceId="srcProducts"
AllowPaging="true"
Runat="server" />
</div>
<div class="floater">
<h3>FormView</h3>
<asp:FormView
id="FormView1"
DataSourceId="srcProducts"
AllowPaging="true"
Runat="server">
<ItemTemplate>
<%#Eval("Title")%>
<i>directed by</i>
<%#Eval("Director")%>
</ItemTemplate>
</asp:FormView>
</div>
<br style="clear:both" />
<div class="floater">
<h3>Repeater</h3>
<asp:Repeater
id="Repeater1"
DataSourceId="srcProducts"
Runat="server">
<ItemTemplate>
<%#Eval("Title")%>
<i>directed by</i>
<%#Eval("Director")%>
</ItemTemplate>
</asp:Repeater>
</div>
<div class="floater">
<h3>ListView</h3>
<asp:ListView
id="ListView1"
DataSourceId="srcProducts"
Runat="server">
<LayoutTemplate>
<div id="itemPlaceholder" runat="server">
</div>
<asp:DataPager ID="pager1" PageSize="3" runat="server">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<%#Eval("Title")%>
<i>directed by</i>
<%#Eval("Director")%>
</ItemTemplate>
</asp:ListView>
</div>
<asp:SqlDataSource
id="srcProducts"
ConnectionString="Data Source=.\SQLExpress;
AttachDbFilename=|DataDirectory|MyDatabase.mdf;
Integrated Security=True;User Instance=True"
SelectCommand="SELECT TOP 5 Title,Director FROM Products"
Runat="server" />
</form>
</body>
</html>