Automatic updates with Entity Framework

3 posts, 0 answers
  1. Adam Hager
    Adam Hager avatar
    9 posts
    Member since:
    Nov 2009

    Posted 13 Nov 2009 Link to this post

    I can't seem to get the Automatic Updates to fire when I move an item from 1 listbox to another.  When I move an item from 1 listbox to another I need to insert that moved record into a table in my db.  Is this functionality even possible?

    <%

    @ Page Language="C#" AutoEventWireup="true" CodeBehind="ShipmentForwardingVendorCrews.aspx.cs"

     

     

    Inherits="Graebel.RITS.Web.Relocations.ShipmentForwardingVendorCrews" %>

     

    <%

    @ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

     

    <%

    @ Register Assembly="System.Web.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

     

     

    Namespace="System.Web.UI.WebControls" TagPrefix="asp" %>

     

    <!

     

    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 runat="server">

     

     

    <title>Shipment Forwarding Vendor Crews</title>

     

     

    <link href="../Graebel.css" rel="stylesheet" />

     

    </

     

    head>

     

    <

     

    body>

     

     

    <form id="ShipmentForwardingVendorCrews" runat="server">

     

     

    <asp:ScriptManager ID="ScriptManager1" runat="server">

     

     

    </asp:ScriptManager>

     

     

    <asp:Panel ID="PageContent" runat="server">

     

     

    <h1>

     

    Shipment Forwarding Vendor Crews

    </h1>

     

     

    <br />

     

     

    <asp:DropDownList ID="ddlODAgent" runat="server" OnSelectedIndexChanged="ddlODAgent_SelectedIndexChanged"

     

     

    AutoPostBack="True">

     

     

    </asp:DropDownList>

     

     

    <br />

     

     

    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">

     

     

    <telerik:RadListBox ID="rlbIsNotCrewLeads" runat="server" Width="200px" Height="200px"

     

     

    SelectionMode="Single" AllowTransfer="True" TransferToID="rlbAssignCrewLeads" AutoPostBackOnReorder="True"

     

     

    EnableDragAndDrop="True" DataSourceID="UnassignedCrewLeadsDataSource" DataKeyField="VendorCrewId"

     

     

    DataTextField="FirstName" DataValueField="VendorCrewId" Skin="Telerik" BorderColor="Black"

     

     

    BorderStyle="Solid" BorderWidth="2px">

     

     

    </telerik:RadListBox>

     

     

    <telerik:RadListBox ID="rlbAssignCrewLeads" runat="server"

     

     

    DataSourceID="AssignedCrewLeads" DataKeyField="VendorCrewId" DataTextField="FirstName"

     

     

    DataValueField="VendorCrewId" Skin="Telerik" AllowAutomaticUpdates="True" Width="200px" Height="200px"

     

     

    BorderColor="Black" BorderStyle="Solid" BorderWidth="2px">

     

     

    </telerik:RadListBox>

     

     

    <br />

     

     

    </telerik:RadAjaxPanel>

     

     

    <asp:EntityDataSource ID="UnassignedCrewLeadsDataSource" runat="server" AutoGenerateWhereClause="True"

     

     

    CommandText="SELECT value crew

     

    FROM VendorCrew AS crew

    WHERE NOT EXISTS(SELECT sfvc.VendorCrew.VendorCrewId

    FROM ShipmentForwardingVendorCrew AS sfvc

    WHERE sfvc.Shipments.ShipmentId = @ShipmentId)

    AND crew.CompanyEntities.CompanyEntityId = @VendorId

    AND crew.IsActive = true

    AND crew.IsCrewLead = true"

     

    ConnectionString="name=RITSNetEntities"

     

     

    DefaultContainerName="RITSNetEntities" Include="ShipmentForwardingVendorCrew,CompanyEntities">

     

     

    <CommandParameters>

     

     

    <asp:QueryStringParameter Name="ShipmentId" QueryStringField="10" Type="Int32" />

     

     

    <asp:ControlParameter ControlID="ddlODAgent" Name="VendorId" PropertyName="SelectedValue"

     

     

    Type="Int32" />

     

     

    </CommandParameters>

     

     

    </asp:EntityDataSource>

     

     

    <asp:EntityDataSource ID="AssignedCrewLeads" runat="server" ConnectionString="name=RITSNetEntities"

     

     

    DefaultContainerName="RITSNetEntities" EnableDelete="True" EnableInsert="True"

     

     

    EnableUpdate="True" Include="VendorCrew" AutoGenerateWhereClause="True" EntitySetName="ShipmentForwardingVendorCrew"

     

     

    Where="">

     

     

    <InsertParameters>

     

     

    <asp:SessionParameter Name="shipmentId" SessionField="10" DbType="Int32" />

     

     

    <asp:SessionParameter DbType="Boolean" Name="IsOriginServicesVendor" SessionField="IsOrigin" />

     

     

    <asp:ControlParameter ControlID="rlbAssignCrewLeads" DefaultValue="true" Name="IsCrewLead"

     

     

    PropertyName="SelectedValue" DbType="Boolean" />

     

     

    </InsertParameters>

     

     

    <UpdateParameters>

     

     

    <asp:SessionParameter Name="shipmentId" SessionField="10" DbType="Int32" />

     

     

    <asp:SessionParameter DbType="Boolean" Name="IsOriginServicesVendor" SessionField="IsOrigin" />

     

     

    <asp:ControlParameter ControlID="rlbAssignCrewLeads" DefaultValue="true" Name="IsCrewLead"

     

     

    PropertyName="SelectedValue" DbType="Boolean" />

     

     

    </UpdateParameters>

     

     

    <WhereParameters>

     

     

    <asp:SessionParameter Name="shipmentId" SessionField="10" DbType="Int32" />

     

     

    <asp:SessionParameter DbType="Boolean" Name="IsOriginServicesVendor" SessionField="IsOrigin" />

     

     

    </WhereParameters>

     

     

    </asp:EntityDataSource>

     

    <%

    --<asp:EntityDataSource ID="UnassignedCrewDataSource" runat="server" AutoGenerateWhereClause="True"

     

    CommandText="SELECT value crew

    FROM VendorCrew AS crew

    WHERE NOT EXISTS(SELECT sfvc.VendorCrew.VendorCrewId

    FROM ShipmentForwardingVendorCrew AS sfvc

    WHERE sfvc.Shipments.ShipmentId = @ShipmentId)

    AND crew.CompanyEntities.CompanyEntityId = @VendorId

    AND crew.IsActive = true" ConnectionString="name=RITSNetEntities"

    DefaultContainerName="RITSNetEntities" Include="ShipmentForwardingVendorCrew,CompanyEntities">

    <CommandParameters>

    <asp:QueryStringParameter Name="ShipmentId" QueryStringField="10" Type="Int32" />

    <asp:ControlParameter ControlID="ddlODAgent" Name="VendorId" PropertyName="SelectedValue"

    Type="Int32" />

    </CommandParameters>

    </asp:EntityDataSource>--

     

    %>

     

    <%

    -- <asp:EntityDataSource ID="AssignedCrewDataSource" runat="server"

     

    AutoGenerateWhereClause="True"

    CommandText="SELECT value crew

    FROM VendorCrew AS crew

    WHERE EXISTS(SELECT sfvc.VendorCrew.VendorCrewId

    FROM ShipmentForwardingVendorCrew AS sfvc

    WHERE sfvc.Shipments.ShipmentId = @ShipmentId)

    AND crew.CompanyEntities.CompanyEntityId = @VendorId

    AND crew.IsActive = true"

    ConnectionString="name=RITSNetEntities"

    DefaultContainerName="RITSNetEntities"

    Include="ShipmentForwardingVendorCrew,CompanyEntities">

    <CommandParameters>

    <asp:QueryStringParameter Name="ShipmentId" QueryStringField="10" Type="Int32" />

    <asp:ControlParameter ControlID="ddlODAgent" Name="VendorId"

    PropertyName="SelectedValue" Type="Int32" />

    </CommandParameters>

    </asp:EntityDataSource>--

     

    %>

     

     

    </asp:Panel>

     

     

    </form>

     

    </

     

    body>

     

    </

     

    html>

     

  2. Vesko
    Vesko avatar
    122 posts
    Member since:
    Mar 2009

    Posted 18 Nov 2009 Link to this post

    Try setting the AllowAutomaticUpdates="True" to the main listbox (source listbox).

    Also, please use the Format Code Block button next time
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 18 Nov 2009 Link to this post

    +1 on the format code block, and only the relevant code.
Back to Top