ItemTemplate in FormView : FormView « ADO.net Database « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » ADO.net Database » FormView 
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
1.Basic FormView
2.Using a FormView control to display and edit data
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.