FormView not updating

M

MasterChief

I have a FormView that won't update at all. I have looked at thing such
as datakeys and making sure the update command is correct but I can't
find the problem. Here is my code. Could the item_id (the primary key)
being evaluated instead of binded have do with it?

<asp:FormView ID="FormView1" runat="server" DataKeyNames="item_id"
DataSourceID="SqlDataSourceEditWork"
DefaultMode="Edit" Height="340px" Width="757px">
<EditItemTemplate>
item_id:
<asp:Label ID="item_idLabel1" runat="server" Text='<%#
Eval("item_id") %>'></asp:Label><br />
item_date:
<asp:TextBox ID="item_dateTextBox" runat="server" Text='<%#
Bind("item_date") %>'></asp:TextBox><br />
item_orderID:
<asp:TextBox ID="item_orderIDTextBox" runat="server"
Text='<%# Bind("item_orderID") %>'></asp:TextBox><br />
item_brdft:
<asp:TextBox ID="item_brdftTextBox" runat="server"
Text='<%# Bind("item_brdft") %>'></asp:TextBox><br />
item_dollars:
<asp:TextBox ID="item_dollarsTextBox" runat="server"
Text='<%# Bind("item_dollars") %>'></asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
item_id:
<asp:Label ID="item_idLabel" runat="server" Text='<%#
Eval("item_id") %>'></asp:Label><br />
item_date:
<asp:Label ID="item_dateLabel" runat="server" Text='<%#
Bind("item_date") %>'></asp:Label><br />
item_orderID:
<asp:Label ID="item_orderIDLabel" runat="server" Text='<%#
Bind("item_orderID") %>'></asp:Label><br />
item_brdft:
<asp:Label ID="item_brdftLabel" runat="server" Text='<%#
Bind("item_brdft") %>'></asp:Label><br />
item_dollars:
<asp:Label ID="item_dollarsLabel" runat="server" Text='<%#
Bind("item_dollars") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server"
CausesValidation="False" CommandName="Delete"
Text="Delete"></asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New"
Text="New"></asp:LinkButton>
</ItemTemplate>
<InsertItemTemplate>
item_date:
<asp:TextBox ID="item_dateTextBox" runat="server" Text='<%#
Bind("item_date") %>'>
</asp:TextBox><br />
item_orderID:
<asp:TextBox ID="item_orderIDTextBox" runat="server"
Text='<%# Bind("item_orderID") %>'>
</asp:TextBox><br />
item_brdft:
<asp:TextBox ID="item_brdftTextBox" runat="server"
Text='<%# Bind("item_brdft") %>'>
</asp:TextBox><br />
item_dollars:
<asp:TextBox ID="item_dollarsTextBox" runat="server"
Text='<%# Bind("item_dollars") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSourceTechnician" runat="server"
ConnectionString="<%$ ConnectionStrings:purchasedWoodConnectionString
%>"
SelectCommand="SELECT [UserName], [UserId] FROM
[vw_aspnet_Users]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSourceEditWork" runat="server"
ConnectionString="<%$ ConnectionStrings:purchasedWoodConnectionString
%>" DeleteCommand="DELETE FROM [items] WHERE [item_id] =
@original_item_id AND [item_date] = @original_item_date AND
[item_orderID] = @original_item_orderID AND [item_brdft] =
@original_item_brdft AND [item_dollars] = @original_item_dollars"
InsertCommand="INSERT INTO [items] ([item_date], [item_orderID],
[item_brdft], [item_dollars]) VALUES (@item_date, @item_orderID,
@item_brdft, @item_dollars)" SelectCommand="SELECT * FROM [items] WHERE
([item_id] = @item_id)" UpdateCommand="UPDATE [items] SET [item_date] =
@item_date, [item_orderID] = @item_orderID, [item_brdft] = @item_brdft,
[item_dollars] = @item_dollars WHERE [item_id] = @original_item_id AND
[item_date] = @original_item_date AND [item_orderID] =
@original_item_orderID AND [item_brdft] = @original_item_brdft AND
[item_dollars] = @original_item_dollars"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="original_{0}">
<DeleteParameters>
<asp:parameter Name="original_item_id" Type="Int32" />
<asp:parameter Name="original_item_date" Type="DateTime" />
<asp:parameter Name="original_item_orderID" Type="String"
/>
<asp:parameter Name="original_item_brdft" Type="Decimal" />
<asp:parameter Name="original_item_dollars" Type="Decimal"
/>
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="item_date" Type="DateTime" />
<asp:parameter Name="item_orderID" Type="String" />
<asp:parameter Name="item_brdft" Type="Decimal" />
<asp:parameter Name="item_dollars" Type="Decimal" />
<asp:parameter Name="original_item_id" Type="Int32" />
<asp:parameter Name="original_item_date" Type="DateTime" />
<asp:parameter Name="original_item_orderID" Type="String"
/>
<asp:parameter Name="original_item_brdft" Type="Decimal" />
<asp:parameter Name="original_item_dollars" Type="Decimal"
/>
</UpdateParameters>
<SelectParameters>
<asp:QueryStringParameter Name="item_id"
QueryStringField="item_id" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:parameter Name="item_date" Type="DateTime" />
<asp:parameter Name="item_orderID" Type="String" />
<asp:parameter Name="item_brdft" Type="Decimal" />
<asp:parameter Name="item_dollars" Type="Decimal" />
</InsertParameters>
</asp:SqlDataSource>
</asp:Content>
 
C

Christopher Reed

Only use the item_id in your WHERE clause for the UpdateCommand.
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

MasterChief said:
I have a FormView that won't update at all. I have looked at thing such
as datakeys and making sure the update command is correct but I can't
find the problem. Here is my code. Could the item_id (the primary key)
being evaluated instead of binded have do with it?

<asp:FormView ID="FormView1" runat="server" DataKeyNames="item_id"
DataSourceID="SqlDataSourceEditWork"
DefaultMode="Edit" Height="340px" Width="757px">
<EditItemTemplate>
item_id:
<asp:Label ID="item_idLabel1" runat="server" Text='<%#
Eval("item_id") %>'></asp:Label><br />
item_date:
<asp:TextBox ID="item_dateTextBox" runat="server" Text='<%#
Bind("item_date") %>'></asp:TextBox><br />
item_orderID:
<asp:TextBox ID="item_orderIDTextBox" runat="server"
Text='<%# Bind("item_orderID") %>'></asp:TextBox><br />
item_brdft:
<asp:TextBox ID="item_brdftTextBox" runat="server"
Text='<%# Bind("item_brdft") %>'></asp:TextBox><br />
item_dollars:
<asp:TextBox ID="item_dollarsTextBox" runat="server"
Text='<%# Bind("item_dollars") %>'></asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update"></asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
item_id:
<asp:Label ID="item_idLabel" runat="server" Text='<%#
Eval("item_id") %>'></asp:Label><br />
item_date:
<asp:Label ID="item_dateLabel" runat="server" Text='<%#
Bind("item_date") %>'></asp:Label><br />
item_orderID:
<asp:Label ID="item_orderIDLabel" runat="server" Text='<%#
Bind("item_orderID") %>'></asp:Label><br />
item_brdft:
<asp:Label ID="item_brdftLabel" runat="server" Text='<%#
Bind("item_brdft") %>'></asp:Label><br />
item_dollars:
<asp:Label ID="item_dollarsLabel" runat="server" Text='<%#
Bind("item_dollars") %>'></asp:Label><br />
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" CommandName="Edit"
Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server"
CausesValidation="False" CommandName="Delete"
Text="Delete"></asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New"
Text="New"></asp:LinkButton>
</ItemTemplate>
<InsertItemTemplate>
item_date:
<asp:TextBox ID="item_dateTextBox" runat="server" Text='<%#
Bind("item_date") %>'>
</asp:TextBox><br />
item_orderID:
<asp:TextBox ID="item_orderIDTextBox" runat="server"
Text='<%# Bind("item_orderID") %>'>
</asp:TextBox><br />
item_brdft:
<asp:TextBox ID="item_brdftTextBox" runat="server"
Text='<%# Bind("item_brdft") %>'>
</asp:TextBox><br />
item_dollars:
<asp:TextBox ID="item_dollarsTextBox" runat="server"
Text='<%# Bind("item_dollars") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSourceTechnician" runat="server"
ConnectionString="<%$ ConnectionStrings:purchasedWoodConnectionString
%>"
SelectCommand="SELECT [UserName], [UserId] FROM
[vw_aspnet_Users]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSourceEditWork" runat="server"
ConnectionString="<%$ ConnectionStrings:purchasedWoodConnectionString
%>" DeleteCommand="DELETE FROM [items] WHERE [item_id] =
@original_item_id AND [item_date] = @original_item_date AND
[item_orderID] = @original_item_orderID AND [item_brdft] =
@original_item_brdft AND [item_dollars] = @original_item_dollars"
InsertCommand="INSERT INTO [items] ([item_date], [item_orderID],
[item_brdft], [item_dollars]) VALUES (@item_date, @item_orderID,
@item_brdft, @item_dollars)" SelectCommand="SELECT * FROM [items] WHERE
([item_id] = @item_id)" UpdateCommand="UPDATE [items] SET [item_date] =
@item_date, [item_orderID] = @item_orderID, [item_brdft] = @item_brdft,
[item_dollars] = @item_dollars WHERE [item_id] = @original_item_id AND
[item_date] = @original_item_date AND [item_orderID] =
@original_item_orderID AND [item_brdft] = @original_item_brdft AND
[item_dollars] = @original_item_dollars"
ConflictDetection="CompareAllValues"
OldValuesParameterFormatString="original_{0}">
<DeleteParameters>
<asp:parameter Name="original_item_id" Type="Int32" />
<asp:parameter Name="original_item_date" Type="DateTime" />
<asp:parameter Name="original_item_orderID" Type="String"
/>
<asp:parameter Name="original_item_brdft" Type="Decimal" />
<asp:parameter Name="original_item_dollars" Type="Decimal"
/>
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="item_date" Type="DateTime" />
<asp:parameter Name="item_orderID" Type="String" />
<asp:parameter Name="item_brdft" Type="Decimal" />
<asp:parameter Name="item_dollars" Type="Decimal" />
<asp:parameter Name="original_item_id" Type="Int32" />
<asp:parameter Name="original_item_date" Type="DateTime" />
<asp:parameter Name="original_item_orderID" Type="String"
/>
<asp:parameter Name="original_item_brdft" Type="Decimal" />
<asp:parameter Name="original_item_dollars" Type="Decimal"
/>
</UpdateParameters>
<SelectParameters>
<asp:QueryStringParameter Name="item_id"
QueryStringField="item_id" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:parameter Name="item_date" Type="DateTime" />
<asp:parameter Name="item_orderID" Type="String" />
<asp:parameter Name="item_brdft" Type="Decimal" />
<asp:parameter Name="item_dollars" Type="Decimal" />
</InsertParameters>
</asp:SqlDataSource>
</asp:Content>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,297
Latest member
EngineerD

Latest Threads

Top