001 <%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeBehind="BooksTest.aspx.cs" Inherits="BooksTest._Default" %>
002 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
003 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
004 <head id="Head1" runat="server">
005     <title>Books</title>
006 	<style type="text/css">
007 		th  {
008 				background-color: Silver;
009 				border: 1 solid #0a0a0a;
010 				padding: 3px 3px 3px 3px;
011 		}
012 		table tbody {
013 				border-collapse: collapse;
014 		 		border: 1 solid #0a0a0a;
015 		}
016		.odd {	background-color: #efefef; }
017 	.even {	background-color: #fefdfd; }
018 	#LVBooks { margin-left: 10px; }
019 	.BookID { text-align: center; }
020 	.outerbox {	position: relative; padding: 0px; height: 140px; }
021 	.innerbox { position: absolute; padding: 0px; height: 100%; overflow: auto; }
022 	.headertable { position: absolute; top: 0; left: 0; z-index: 100; }
023 	td input { width: 99%; }
024 	td { font: Verdana 8pt; }
025 	</style>
026 </head>
027 <body>
028 	<h1>Books</h1>
029 	<form id="Form1" runat="server">
030 	<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
031 	<asp:SqlDataSource	ID="sdsBooks" runat="server"
032 						DataSourceMode="DataReader"
033 						ConnectionString="Data Source=xxxxxx;Integrated Security=True;Initial Catalog=Data;"
034 						SelectCommand="GetBooks"
035 						SelectCommandType="StoredProcedure"
036 						UpdateCommand="UpdateBooks"
037 						UpdateCommandType="StoredProcedure"
038 						CancelSelectOnNullParameter="False">
039 			<UpdateParameters>
040 				<asp:Parameter Name="BookId" DbType="Int32" />
041 				<asp:Parameter Name="Title" DbType="String" />
042 				<asp:Parameter Name="Author" DbType="String" />
043 				<asp:Parameter Name="Isbn" DbType="String" />
044 				<asp:Parameter Name="Publisher" DbType="String" />
045 			</UpdateParameters>
046 		</asp:SqlDataSource>
047 		<div class="outerbox">
048 			<asp:UpdatePanel ID="updBooks" runat="server">
049 			<ContentTemplate>
050 			<asp:ListView	ID="LVBooks" runat="server"
051 							ItemPlaceholderID="ItemDataRow"
052 							DataSourceID="sdsBooks">
053 				<LayoutTemplate>
054 					<table class="headertable" rules="all" border="1">
055 						<thead>
056 							<tr>
057 								<th style="width: 60px">BookId</th>
058 								<th style="width: 180px">Title</th>
059 								<th style="width: 120px">Author</th>
060 								<th style="width: 120px">ISBN</th>
061 								<th style="width: 120px">Publisher</th>
062 								<th style="width: 120px">Action</th>
063 							</tr>
064 						</thead>
065 					</table>
066 					<div class="innerbox">
067 					<table class="datatable" rules="all" border="1">
068 						<thead>
069 							<tr>
070 								<th style="width: 60px">BookId</th>
071 								<th style="width: 180px">Title</th>
072 								<th style="width: 120px">Author</th>
073 								<th style="width: 120px">ISBN</th>
074 								<th style="width: 120px">Publisher</th>
075 								<th style="width: 120px">Action</th>
076 							</tr>
077 						</thead>
078 						<tbody>
079 							<tr id="ItemDataRow" runat="server" />
080 						</tbody>
081 					</table>
082 					</div>
083 				</LayoutTemplate>
084 				<ItemTemplate>
085 					<tr>
086 						<td class="BookID"><%#Eval("BookId") %></td>
087 						<td><asp:Label ID="lblTitle" runat="server" Text='<%#Eval("Title") %>' /></td>
088 						<td><asp:Label ID="lblAuthor" runat="server" Text='<%#Eval("Author") %>' /></td>
089 						<td><asp:Label ID="lblIsbn" runat="server" Text='<%#Eval("ISBN") %>' /></td>
090 						<td><asp:Label ID="lblPublisher" runat="server" Text='<%#Eval("Publisher") %>' /></td>
091 						<td><asp:LinkButton ID="lbEdit" runat="server" Text="Edit" CommandName="Edit" /></td>
092 					</tr>
093 				</ItemTemplate>
094 				<EditItemTemplate>
095 						<td class="BookID"><asp:Label ID="lblBookId" runat="server" Text='<%#Bind("BookId") %>' /></td>
096 						<td><asp:TextBox ID="txtTitle" runat="server" Text='<%#Bind("Title") %>' /></td>
097 						<td><asp:TextBox ID="txtAuthor" runat="server" Text='<%#Bind("Author") %>' /></td>
098 						<td><asp:TextBox ID="txtIsbn" runat="server" Text='<%#Bind("ISBN") %>' /></td>
099 						<td><asp:TextBox ID="txtPublisher" runat="server" Text='<%#Bind("Publisher") %>' /></td>
100 						<td>
101 							<asp:LinkButton ID="lbUpdate" runat="server" Text="Update" CommandName="Update" />
102 							<asp:LinkButton ID="lbCancel" runat="server" Text="Cancel" CommandName="Cancel" />
103 						</td>
104 				</EditItemTemplate>
105 			</asp:ListView>
106 			</ContentTemplate>
107 			</asp:UpdatePanel>
108  		</div>
109     </form>
110 </body>
111 </html>
112 <script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
113 <script type="text/javascript">
114 	$(document).ready(StyleTable());
115 	function StyleTable() {
116 		$("table tr:odd").addClass("odd");
117 		$("table tr:even").addClass("even");
119 	}
120 	var pgmgr = Sys.WebForms.PageRequestManager.getInstance();
121 	pgmgr.add_beginRequest(BeginRequestHandler);
122 	pgmgr.add_endRequest(EndRequestHandler);
123 	function BeginRequestHandler(sender, args) {
124 		var elem = args.get_postBackElement();
125 	}
126 	function EndRequestHandler(sender, args) {
127 		StyleTable();
128 	}
129 </script>