ItemTemplate in FormView
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Edit FormView</title>
</head>
<body>
<form id="form1" runat="server">
<div id="container">
Book Details
<asp:FormView ID="frmvBooks" runat="server" DataSourceID="dsBooks"
AllowPaging="true" DataKeyNames="Isbn">
<ItemTemplate>
ISBN: <br />
<asp:Label ID="labIsbn" runat="server"
Text='<%# Eval("ISBN") %>' /><br />
Title:<br />
<asp:Label ID="labTitle" runat="server"
Text='<%# Eval("Title") %>' /><br />
Publisher:<br />
<asp:Label ID="labPublisher" runat="server"
Text='<%# Eval("PublisherName") %>' /><br />
Year:<br />
<asp:Label ID="labYear" runat="server"
Text='<%# Eval("YearPublished") %>' /><br />
Description:<br />
<asp:Label ID="txtDecs" runat="server"
Text='<%# Eval("BriefDescription") %>' /><br/>
</div>
</ItemTemplate>
<EmptyDataTemplate>
No book matched this ISBN
</EmptyDataTemplate>
<PagerStyle CssClass="singleBookTitle" />
<PagerSettings Mode="NextPreviousFirstLast"
FirstPageImageUrl="images/page_first.gif"
LastPageImageUrl="images/page_last.gif"
NextPageImageUrl="images/page_next.gif"
PreviousPageImageUrl="images/page_previous.gif"/>
</asp:FormView>
</div>
<asp:SqlDataSource ID="dsBooks" runat="server"
ProviderName="System.Data.OleDb"
ConnectionString="<%$ ConnectionStrings:Books %>"
SelectCommand="SELECT ISBN,Title,PublisherName,Books.PublisherId,YearPublished,BriefDescription FROM Books INNER JOIN Publishers ON Books.PublisherId=Publishers.PublisherId WHERE ISBN=@isbn">
<SelectParameters>
<asp:QueryStringParameter Name="isbn" QueryStringField="id" />
</SelectParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
Related examples in the same category