Formview not updating data correctly

Discussion in 'ASP .Net' started by Cirene, May 23, 2008.

  1. Cirene

    Cirene Guest

    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>
     
    Cirene, May 23, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MasterChief

    FormView not updating

    MasterChief, Feb 23, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    4,627
    Christopher Reed
    Mar 2, 2006
  2. Dan Sikorsky
    Replies:
    1
    Views:
    1,869
    Sheng Jiang[MVP]
    Jan 2, 2007
  3. news.rcn.com
    Replies:
    2
    Views:
    1,182
    Roedy Green
    Dec 10, 2007
  4. John Mason
    Replies:
    0
    Views:
    432
    John Mason
    Jul 22, 2008
  5. David Thielen

    FormView/Repeater/ Eval(FormView data)

    David Thielen, Jun 16, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    714
    David Thielen
    Jun 16, 2006
Loading...

Share This Page