Update Query in formview

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Greetings all!

After a week of toiling I've finallay decided to post the code below with
hopes that someone can point out my error(s).

Basically I have a Gridview/Formview on a ASP.NEt 2.0 page.
When I select a record on the Gridview I'm presented with the corresponding
FormView Template for Editing. Works fine!

ItemTemplate in FormView works fine...Edit button takes me Edit Template!

However...

Upon clicking the Update button on the item Tempalte (With the associated
SqlDataSource associated below my data fails to update.)

I'm sure my error is obvious but I just cannot find it.


<asp:SqlDataSource ID="REACTOR_AHTs" runat="server"
ConnectionString="<%$
ConnectionStrings:REACTORConnectionString % %>"
ProviderName="<%$
ConnectionStrings:REACTORConnectionString.ProviderName %>"
OldValuesParameterFormatString="original_{0}"
SelectCommand=
"SELECT CaseCounter,
Condition_of_Animal,
TreatmentCardHistory
FROM Animal_Health_Records
WHERE (CaseCounter = @CaseCounter)"

UpdateCommand=
"UPDATE Animal_Health_Records
SET Condition_of_Animal = @Condition_of_Animal,
TreatmentCardHistory = @TreatmentCardHistory
WHERE (Animal_Health_Records.CaseCounter =
@original_CaseCounter)">

<DeleteParameters>
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Condition_of_Animal" Type="String" />
<asp:Parameter Name="TreatmentCardHistory" Type="String"
/>
<asp:ControlParameter ControlID="grdREACTOR"
Name="original_CaseCounter" PropertyName="SelectedValue" Type="Int32" />
</UpdateParameters>

<SelectParameters>
<asp:ControlParameter ControlID="grdREACTOR"
Name="CaseCounter" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
 
No visible errors.. the updates just fails to be posted. the formview simply
reverts to the ItemTemplate and datsa remains unchanged!
 
Hi Marcial, try this & let me know if it still doesn't work

UpdateCommand=
"UPDATE [Animal_Health_Records] SET [Condition_of_Animal] = ?,
[TreatmentCardHistory] = ? WHERE
[Animal_Health_Records.CaseCounter] =?

<UpdateParameters>
<asp:Parameter Name="Condition_of_Animal" Type="String" />
<asp:Parameter Name="TreatmentCardHistory" Type="String "/>
<asp:Parameter
Name="Animal_Health_Records.CaseCounter"Type="String"/>
</UpdateParameters>

n.b: check again the Animal_Health_Records.CaseCounter data type
 
Back
Top