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

Two Clicks to update calculated column

3 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
grand lorie
Top achievements
Rank 1
grand lorie asked on 07 Apr 2010, 10:39 AM
Hi

I have a Grid with Calculated Columns
- when the user clicks edit button he enters the unit cost of an item.
- then the Item Cost is calculated automaticaly (Number of Pages * Unit Cost).
- Unit Cost is in Orders Table and Number of Pages is on Item Table.
- Everything is working fine except the user has to click two times on Edit to update the Item Cost, as for the first edit the user enters the Unit Cost and by clicking Update the Unit Cost columns updated correctly but the Item Cost column does not and the user needs to click edit again and click update again (without any change) to update the Item Cost Column.

Can the Item Cost update automaticaly when the user clicks update the first time.

here is my SqlDataSource:
-----------------------------------------------------
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:OrderSystemConn %>"
        DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID"
        InsertCommand="INSERT INTO Orders(DaysLeft, StatusID, ItemCost) VALUES (@DaysLeft, @StatusID,)"
        SelectCommand="SELECT Orders.OrderID, Orders.OrderDate, Orders.Quantity, Orders.ManageDate, Orders.OrderSpecs, Orders.ManageSubmit, Orders.ManageComment, Orders.DaysLeft, Orders.FinishDate, Orders.ItemID, Orders.StatusID, Status.StatusName, Orders.SupplierID, Division.DivisionName, Category.CategoryName, Type.TypeName, Item.FullCode, Version.VersionName, Orders.UnitCost, Orders.ItemCost, Orders.TotalCost, Item.PagesNumber FROM Orders INNER JOIN Status ON Orders.StatusID = Status.StatusID INNER JOIN Item ON Orders.ItemID = Item.ItemID INNER JOIN Category ON Item.CategoryID = Category.CategoryID INNER JOIN Division ON Item.DivisionID = Division.DivisionID INNER JOIN Type ON Item.TypeID = Type.TypeID INNER JOIN Version ON Item.VersionID = Version.VersionID WHERE (Orders.ManageSubmit = 1) AND (Orders.StatusID &lt;&gt; 3) AND (Orders.SupplierID = 2) ORDER BY Orders.FinishDate"         
        
        UpdateCommand="UPDATE Orders SET UnitCost = @UnitCost,  ItemCost = Orders.UnitCost * Item.PagesNumber FROM Orders INNER JOIN Item ON Orders.ItemID = Item.ItemID WHERE (Orders.OrderID = @OrderID)">
        <DeleteParameters>
            <asp:Parameter Name="OrderID" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="UnitCost" />
            <asp:Parameter Name="OrderID" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="DaysLeft" />
            <asp:Parameter Name="StatusID" />
        </InsertParameters>
    </asp:SqlDataSource>
-------------------------------------------------------

3 Answers, 1 is accepted

Sort by
0
grand lorie
Top achievements
Rank 1
answered on 09 Apr 2010, 12:51 PM
anyone to help???
0
Tsvetoslav
Telerik team
answered on 12 Apr 2010, 08:18 AM
Hello grand,

Try chaning the UpdateCommand to the following:

UpdateCommand="UPDATE Orders SET UnitCost = @UnitCost,  ItemCost = @UnitCost * Item.PagesNumber FROM Orders INNER JOIN Item ON Orders.ItemID = Item.ItemID WHERE (Orders.OrderID = @OrderID)">

Hope it helps.

Regards,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
grand lorie
Top achievements
Rank 1
answered on 12 Apr 2010, 09:06 AM
Tsvetoslav

that did the trick

Many thanks
Lorie
Tags
Grid
Asked by
grand lorie
Top achievements
Rank 1
Answers by
grand lorie
Top achievements
Rank 1
Tsvetoslav
Telerik team
Share this question
or