By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,364 Members | 1,272 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,364 IT Pros & Developers. It's quick & easy.

Formview not updating data correctly

P: n/a
I have a formview that is calling a stored procedure (thru an sqldatasource)
to update 2 tables. When I execute the update it runs fine, with no errors.
But the data does NOT change. Any ideas why?

Here's the stored proc, the datasource and the edit template of the
formview...

***************STORED PROC*******************
ALTER PROCEDURE dbo.UpdateCompanyUsers
(
@UserId uniqueidentifier,
@CompanyUserId int,
@CompanyId int,
@FirstName nvarchar(MAX),
@LastName nvarchar(MAX),
@Phone nvarchar(MAX),
@Phone2 nvarchar(MAX),
@Fax nvarchar(MAX),
@Email nvarchar(MAX)
)
AS

BEGIN
UPDATE CompanyUsers
SET
CompanyId=@CompanyId,
FirstName=@FirstName,
LastName=@LastName,
Phone=@Phone,
Phone2=@Phone2,
Fax=@Fax
WHERE (CompanyUserId = @CompanyUserId)

UPDATE dbo.aspnet_Membership WITH (ROWLOCK)
SET
Email = @Email,
LoweredEmail = LOWER(@Email)
WHERE
@UserId = UserId

RETURN
END

****************SQL DATA SOURCE********************
<asp:SqlDataSource ID="sdsUser" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
:
UpdateCommand="UpdateCompanyUsers"
UpdateCommandType="StoredProcedure">
:
<UpdateParameters>
<asp:Parameter Name="UserId" />
<asp:Parameter Name="CompanyUserId" Type="Int32" />
<asp:Parameter Name="CompanyId" Type="Int32" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="Phone" Type="String" />
<asp:Parameter Name="Phone2" Type="String" />
<asp:Parameter Name="Fax" Type="String" />
<asp:Parameter Name="Email" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>

*******************FORM VIEW EDIT TEMPLATE**********************
<EditItemTemplate>
<table class="style1">
<tr>
<td class="style2">
Company:</td>
<td>
<telerik:RadComboBox ID="RadComboBox1"
Runat="server"
DataSourceID="sdsCompanies"
DataTextField="CompanyName"
DataValueField="CompanyId"
SelectedValue='<%# Bind("CompanyId") %>'>
<CollapseAnimation Duration="200"
Type="OutQuint" />
</telerik:RadComboBox>
</td>
</tr>
<tr>
<td class="style2">
First Name:</td>
<td>
<asp:TextBox ID="FirstNameTextBox"
runat="server"
Text='<%# Bind("FirstName") %>' />
</td>
</tr>
<tr>
<td class="style2">
Last Name:</td>
<td>
<asp:TextBox ID="LastNameTextBox"
runat="server"
Text='<%# Bind("LastName") %>' />
</td>
</tr>
<tr>
<td class="style2">
Phone:</td>
<td>
<asp:TextBox ID="PhoneTextBox"
runat="server" Text='<%# Bind("Phone") %>' />
</td>
</tr>
<tr>
<td class="style2">
Phone2:</td>
<td>
<asp:TextBox ID="Phone2TextBox"
runat="server" Text='<%# Bind("Phone2") %>' />
</td>
</tr>
<tr>
<td class="style2">
Fax:</td>
<td>
<asp:TextBox ID="FaxTextBox" runat="server"
Text='<%# Bind("Fax") %>' />
</td>
</tr>
<tr>
<td class="style2">
Email:</td>
<td>
<asp:TextBox ID="EmailTextBox"
runat="server" Text='<%# Bind("Email") %>' />
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="CompanyUserIdLabel1"
runat="server"
Text='<%# Eval("CompanyUserId") %>'
Visible="False" />
</td>
<td>
<asp:Label ID="Label1" runat="server"
Text='<%# Eval("UserId") %>'
Visible="False"></asp:Label>
</td>
</tr>
</table>
&nbsp;<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True"
CommandName="Update" Text="Update" />
&nbsp;<asp:LinkButton ID="UpdateCancelButton"
runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel" />
</EditItemTemplate>
Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.