Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 8.51 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ASP.NET Data Binding from CodeBehind
  2. <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SummaryForm.ascx.cs" Inherits="RamRideOps.Controls.SummaryForm" %>
  3.  
  4. <asp:EntityDataSource ID="Rides_EDS" runat="server"
  5. ConnectionString="name=RamRideOpsEntities"
  6. DefaultContainerName="RamRideOpsEntities" EnableFlattening="False"
  7. EntitySetName="Rides" EntityTypeFilter="Ride" EnableDelete="True"
  8. EnableInsert="True" EnableUpdate="True">
  9. </asp:EntityDataSource>
  10.  
  11. <asp:ListView ID="SummaryLV" runat="server" DataKeyNames="TimeOfCall"
  12. DataSourceID="Rides_EDS" InsertItemPosition="LastItem"
  13. onselectedindexchanged="ListView1_SelectedIndexChanged">
  14. <AlternatingItemTemplate>
  15.     <tr style="background-color:#FFF8DC;">          
  16.         <td>
  17.             <asp:Label ID="TimeOfCallLabel" runat="server"
  18.                 Text='<%# Eval("TimeOfCall") %>' />
  19.         </td>          
  20.         <td>
  21.             <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
  22.         </td>
  23.         <td>
  24.             <asp:Label ID="PhoneLabel" runat="server" Text='<%# Eval("Phone") %>' />
  25.         </td>
  26.         <td>
  27.             <asp:Label ID="NumPatronsLabel" runat="server"
  28.                 Text='<%# Eval("NumPatrons") %>' />
  29.         </td>
  30.         <td>
  31.             <asp:Label ID="PickupAddressLabel" runat="server"
  32.                 Text='<%# Eval("PickupAddress") %>' />
  33.         </td>            
  34.         <td>
  35.             <asp:Label ID="DropoffAddressLabel" runat="server"
  36.                 Text='<%# Eval("DropoffAddress") %>' />
  37.         </td>
  38.         <td>
  39.             <asp:Label ID="StatusLabel" runat="server" Text='<%# Eval("Status") %>' />
  40.         </td>
  41.         <td>
  42.             <asp:Label ID="AssignedCarLabel" runat="server"
  43.                 Text='<%# Eval("AssignedCar") %>' />
  44.         </td>
  45.         <td>
  46.             <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
  47.             <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delt" />                
  48.         </td>
  49.     </tr>
  50. </AlternatingItemTemplate>
  51. <EditItemTemplate>
  52.     <tr style="background-color:#008A8C;color: #FFFFFF;">
  53.         <td>
  54.             <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
  55.         </td>
  56.         <td>
  57.             <asp:TextBox ID="PhoneTextBox" runat="server" Text='<%# Bind("Phone") %>' />
  58.         </td>
  59.         <td>
  60.             <asp:TextBox ID="NumPatronsTextBox" runat="server"
  61.                 Text='<%# Bind("NumPatrons") %>' />
  62.         </td>
  63.         <td>
  64.             <asp:TextBox ID="PickupAddressTextBox" runat="server"
  65.                 Text='<%# Bind("PickupAddress") %>' />
  66.         </td>            
  67.         <td>
  68.             <asp:TextBox ID="DropoffAddressTextBox" runat="server"
  69.                 Text='<%# Bind("DropoffAddress") %>' />
  70.         </td>
  71.         <td>
  72.             <asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>' />
  73.         </td>
  74.         <td>
  75.             <asp:TextBox ID="AssignedCarTextBox" runat="server"
  76.                 Text='<%# Bind("AssignedCar") %>' />
  77.         </td>
  78.         <td>
  79.             <asp:Button ID="UpdateButton" runat="server" CommandName="Update"
  80.                 Text="Update" />
  81.             <asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
  82.                 Text="Cancel" />
  83.         </td>
  84.     </tr>
  85. </EditItemTemplate>
  86. <EmptyDataTemplate>
  87.     <table runat="server"
  88.         style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
  89.         <tr runat="server">
  90.             <td runat="server">
  91.                 There are currently no scheduled rides!</td>
  92.         </tr>
  93.     </table>
  94. </EmptyDataTemplate>
  95. <InsertItemTemplate>
  96.     <tr style="">
  97.         <td>
  98.             <asp:TextBox ID="TimeOfCallTextBox" runat="server"
  99.                 Text='<%# Bind("TimeOfCall") %>' Visible="False" />
  100.         </td>
  101.         <td>
  102.             <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
  103.         </td>
  104.         <td>
  105.             <asp:TextBox ID="PhoneTextBox" runat="server" Text='<%# Bind("Phone") %>' />
  106.         </td>
  107.         <td>
  108.             <asp:TextBox ID="NumPatronsTextBox" runat="server"
  109.                 Text='<%# Bind("NumPatrons") %>' />
  110.         </td>
  111.         <td>
  112.             <asp:TextBox ID="PickupAddressTextBox" runat="server"
  113.                 Text='<%# Bind("PickupAddress") %>' />
  114.         </td>
  115.         <td>
  116.             <asp:TextBox ID="DropoffAddressTextBox" runat="server"
  117.                 Text='<%# Bind("DropoffAddress") %>' />
  118.         </td>
  119.         <td>
  120.             <asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>' Visible="True" />
  121.         </td>
  122.         <td>
  123.             <asp:TextBox ID="AssignedCarTextBox" runat="server"
  124.                 Text='<%# Bind("AssignedCar") %>' />
  125.         </td>
  126.         <td>
  127.             <asp:Button ID="InsertButton" runat="server" CommandName="Insert"
  128.                 Text="Add" OnClientClick="addButton_Click" />
  129.             <asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
  130.                 Text="Clear" />
  131.         </td>
  132.     </tr>
  133. </InsertItemTemplate>
  134. <ItemTemplate>
  135.     <tr style="background-color:#DCDCDC;color: #000000;">    
  136.         <td>
  137.             <asp:Label ID="TimeOfCallLabel" runat="server"
  138.                 Text='<%# Eval("TimeOfCall") %>' />
  139.         </td>          
  140.         <td>
  141.             <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("Name") %>' />
  142.         </td>
  143.         <td>
  144.             <asp:Label ID="PhoneLabel" runat="server" Text='<%# Eval("Phone") %>' />
  145.         </td>
  146.         <td>
  147.             <asp:Label ID="NumPatronsLabel" runat="server"
  148.                 Text='<%# Eval("NumPatrons") %>' />
  149.         </td>
  150.         <td>
  151.             <asp:Label ID="PickupAddressLabel" runat="server"
  152.                 Text='<%# Eval("PickupAddress") %>' />
  153.         </td>            
  154.         <td>
  155.             <asp:Label ID="DropoffAddressLabel" runat="server"
  156.                 Text='<%# Eval("DropoffAddress") %>' />
  157.         </td>
  158.         <td>
  159.             <asp:Label ID="StatusLabel" runat="server" Text='<%# Eval("Status") %>' />
  160.         </td>
  161.         <td>
  162.             <asp:Label ID="AssignedCarLabel" runat="server"
  163.                 Text='<%# Eval("AssignedCar") %>' />
  164.         </td>
  165.         <td>
  166.             <asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
  167.             <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delt" />                
  168.         </td>
  169.     </tr>
  170. </ItemTemplate>
  171.  
  172. <LayoutTemplate>
  173.     <table runat="server">
  174.         <tr runat="server">
  175.             <td runat="server">
  176.                 <table ID="itemPlaceholderContainer" runat="server" border="1"
  177.                     style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
  178.                     <tr runat="server" style="background-color:#DCDCDC;color: #000000;">
  179.                         <th runat="server" style="width:auto">
  180.                             Call Time</th>                            
  181.                         <th runat="server" style="width:auto">
  182.                             Name</th>
  183.                         <th runat="server" style="width:5px">
  184.                             Phone</th>
  185.                         <th runat="server" style="width:auto">
  186.                             Size</th>
  187.                         <th runat="server" style="width:auto">
  188.                             Pick-Up</th>
  189.                         <th runat="server" style="width:auto">
  190.                             Drop-Off</th>
  191.                         <th runat="server" style="width:auto">
  192.                             Status</th>
  193.                         <th runat="server" style="width:auto">
  194.                             Car</th>
  195.                         <th id="Th1" runat="server">
  196.                             </th>
  197.                     </tr>
  198.                     <tr ID="itemPlaceholder" runat="server">
  199.                     </tr>
  200.                 </table>
  201.             </td>
  202.         </tr>
  203.         <tr runat="server">
  204.             <td runat="server"
  205.                 style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
  206.                 <asp:DataPager ID="DataPager1" runat="server">
  207.                     <Fields>
  208.                         <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
  209.                             ShowLastPageButton="True" />
  210.                     </Fields>
  211.                 </asp:DataPager>
  212.             </td>
  213.         </tr>
  214.     </table>
  215. </LayoutTemplate>