You can do it like this:
Change your method with this one
public void UpdateAnimal(int animalId, string name, bool vertebrates, bool vegetarian, string newsAdress)
{
}
and your ObjectDataSource
<asp:ObjectDataSource ID="ObjectDataSourceAnimals" runat="server" DeleteMethod="DeleteAnimal" SelectMethod="GetAllAnimals" TypeName="BLProject.Animal" UpdateMethod="UpdateAnimal">
<DeleteParameters>
<asp:Parameter Name="a" Type="Object" />
<asp:SessionParameter Name="newsAdress" SessionField="Adress" Type="String" />
</DeleteParameters>
<SelectParameters>
<asp:ControlParameter ControlID="textSearch" Name="Search" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="dropdownlistAnimalToSearch" Name="type" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="animalId" Type="Int32"/>
.......the other fields from Animal that you want to update
<asp:Parameter Name="name" Type="String"/>
<asp:Parameter Name="vegetarian" Type="Boolean"/>
<asp:Parameter Name="vertebrates" Type="Boolean"/>
<asp:SessionParameter DefaultValue="D:\\project\\Ilan Project 29-11\\Web\\NewsInfo" Name="newsAdress" SessionField="Adress" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
Seems that when using DataObjectTypeName
you cannot add parameters. The solution is to send some or all the properties of the Animal
row edited as parameters plus the other parameter.
If you want to use OldValuesParameterFormatString="original_{0}"
, add this int original_animalid
to the method input parameters.