Hello all,
I have used sqldatasource many times calling e.newvalues, and e.oldvalues in the
iteminserting, itemupdating, itemdeleting subs.
When I try using them with the objectdatasource they return no value, which I am assuming they aren't finding the fields.
is anyone having the same problem? I can't figure out what I am doing wrong.
Any help would be appreciated.
code behind --------------------------------------------------------------------------
Protected Sub FormViewAccountSettings_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewUpdateEventArgs) Handles FormViewAccountSettings.ItemUpdating
'insert new image
e.NewValues("ProfilePicture") = e.OldValues("ProfilePicture")
'Insert new password
e.NewValues("UserPassword") = e.OldValues("UserPassword")
End Sub
------------------------------------------------------------------------
------------------------------------------------------------------------
<asp:FormView ID="FormViewAccountSettings" runat="server" DataKeyNames="UserAccountsID" DataSourceID="ObjectDataSourceAccountSettings" DefaultMode="Edit">
<EditItemTemplate>
<div style="padding: 7px; border: 1px solid #aeadad; margin: 0px; background-color: #FFFFFF;">
<div style="padding: 3px; border: 1px solid #aeadad;">
<table style="width: 100%">
<tr>
<td style="width: 225px" align="right">
Nickname:</td>
<td>
<asp:TextBox runat="server" id="nickname" Width="242px" Text='<%# Bind("Nickname")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 225px" align="right">
Gender:</td>
<td>
<asp:DropDownList runat="server" id="GenderDD" Selectedvalue='<%# Bind("Gender")%>'>
<asp:ListItem Text="Male" Value="Male"></asp:ListItem>
<asp:ListItem Text="Female" Value="Female"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="width: 225px"> </td>
<td> </td>
</tr>
<tr>
<td style="width: 225px" align="right">First
Name:</td>
<td>
<asp:TextBox runat="server" id="FirstName" Width="242px" Text='<%# Bind("FirstName")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 225px" align="right">Last
Name:</td>
<td>
<asp:TextBox runat="server" id="LastName" Width="242px" Text='<%# Bind("LastName")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 225px"> </td>
<td> </td>
</tr>
<tr>
<td style="width: 225px" align="right">
Profile Photo:</td>
<td>
<asp:FileUpload runat="server" id="FileUploadProfilePhoto" Width="377px" /></td>
</tr>
<tr>
<td style="width: 225px"> </td>
<td> </td>
</tr>
<tr>
<td style="width: 225px" align="right">Email</td>
<td>
<asp:TextBox runat="server" id="Email" Width="201px" Text='<%# Bind("Email")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 225px"> </td>
<td> </td>
</tr>
<tr>
<td style="width: 225px; height: 23px" align="right">
Password1:</td>
<td style="height: 23px">
<asp:TextBox runat="server" id="Password1" Width="242px" TextMode="Password">
</asp:TextBox><asp:CompareValidator ID="CompareValidatorPassword" runat="server" ErrorMessage="Passwords must match" ControlToCompare="Password1" ControlToValidate="Password2">*</asp:CompareValidator>
</td>
</tr>
<tr>
<td style="width: 225px" align="right">
Password2:</td>
<td>
<asp:TextBox runat="server" id="Password2" Width="242px" TextMode="Password">
</asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 225px"> </td>
<td> </td>
</tr>
<tr>
<td style="width: 225px" align="right">Hint
Question:</td>
<td>
<asp:TextBox runat="server" id="HintQuestion" Width="242px" TextMode="MultiLine" Height="50px" Text='<%# Bind("HintQuestion")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 225px" align="right">Hint
Answer:</td>
<td>
<asp:TextBox runat="server" id="HintAnswer" Width="242px" Text='<%# Bind("HintAnswer")%>'>
</asp:TextBox>
</td>
</tr>
<tr>
<td style="width: 225px" align="right"></td>
<td align="right">
<asp:LinkButton ID="ButtonUpdate" runat="server" Text="Update" CommandName="Update"></asp:LinkButton>
</td>
</tr>
</table>
</div>
</EditItemTemplate>
</asp:FormView>
</div>
<asp:ObjectDataSource ID="ObjectDataSourceAccountSettings" runat="server"
SelectMethod="GetAccountSettings" UpdateMethod="UpdateAccountSettings" TypeName="Dal">
<SelectParameters>
<asp:SessionParameter Name="UserAccountsID" SessionField="UserAccountsID" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="ProfilePicture" />
</UpdateParameters>
</asp:ObjectDataSource>
-----------------------------------------------------------------------------------