This is a migrated thread and some comments may be shown as answers.

Automatic updates with Entity Framework

2 Answers 45 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Adam Hager
Top achievements
Rank 1
Adam Hager asked on 14 Nov 2009, 03:24 AM
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 Answers, 1 is accepted

Sort by
0
Vesko
Top achievements
Rank 2
answered on 18 Nov 2009, 01:17 PM
Try setting the AllowAutomaticUpdates="True" to the main listbox (source listbox).

Also, please use the Format Code Block button next time
0
Mark Galbreath
Top achievements
Rank 2
answered on 18 Nov 2009, 04:04 PM
+1 on the format code block, and only the relevant code.
Tags
ListBox
Asked by
Adam Hager
Top achievements
Rank 1
Answers by
Vesko
Top achievements
Rank 2
Mark Galbreath
Top achievements
Rank 2
Share this question
or