FormView update not updating with ObjectDataSource

Discussion in 'ASP .Net' started by =?Utf-8?B?RGFiYmxlcg==?=, Apr 13, 2006.

  1. I have a FormView tied to ObjectDataSource that's not updating and am
    wondering what I missed..

    <asp:FormView ID="fvRegDetail" runat="server" DefaultMode="Edit"
    DataKeyNames="RegistrantId" DataSourceID="odsRegistrant"
    CssClass="waFormView" >
    <EditItemTemplate>
    ....
    <asp:Button ID="UpdateButton" runat="server" CausesValidation="True"
    CommandName="Update" Text="Update" ValidationGroup="regForm">
    </asp:Button>

    <asp:ObjectDataSource ID="odsRegistrant" runat="server"
    TypeName="RegistrantDB" SelectMethod="GetRegistrant"
    UpdateMethod="UpdateRegistrant" DataObjectTypeName="RegistrantDetails"
    ConvertNullToDBNull="true">
    <SelectParameters>
    <asp:SessionParameter DefaultValue="60" Name="registrantId"
    SessionField="RegistrantId"
    Type="Int32" />
    </SelectParameters>
    <UpdateParameters>
    <asp:parameter Name="firstName" Type="String" />
    <asp:parameter Name="mI" Type="String" />
    <asp:parameter Name="lastName" Type="String" />
    <asp:parameter Name="eMail" Type="String" />
    ...

    My TypeName has:
    public void UpdateRegistrant( RegistrantDetails reg ) {
    SqlConnection con = new SqlConnection( connectionString );
    SqlCommand cmd = new SqlCommand( "UpdateRegistrant", con );
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add( new SqlParameter( "@FirstName", SqlDbType.NVarChar,
    25 ) );
    cmd.Parameters["@FirstName"].Value = reg.FirstName == null ? "" :
    reg.FirstName;
    ....

    And my DataObjectTypeName has:
    public RegistrantDetails(){}
    protected string firstName = String.Empty;
    public string FirstName
    {
    get {return firstName;}
    set {if (value != null){firstName = value;}}
    }
    ....

    Thanks for any clues as to what I must have missed. No exceptions are
    generated and debugger shows the set and update methods aren't invoked.

    Thanks much.
    =?Utf-8?B?RGFiYmxlcg==?=, Apr 13, 2006
    #1
    1. Advertising

  2. I figured out the problem. A validation control was actually tripping and
    keeping the page from updating. For some reason the validation controls don't
    display errors or the validation summary in Firefox. But when I tested in IE
    I found the error message. I was hoping cross browser support had improved in
    ASP.NET v2.0.

    "Dabbler" wrote:

    > I have a FormView tied to ObjectDataSource that's not updating and am
    > wondering what I missed..
    >
    > <asp:FormView ID="fvRegDetail" runat="server" DefaultMode="Edit"
    > DataKeyNames="RegistrantId" DataSourceID="odsRegistrant"
    > CssClass="waFormView" >
    > <EditItemTemplate>
    > ....
    > <asp:Button ID="UpdateButton" runat="server" CausesValidation="True"
    > CommandName="Update" Text="Update" ValidationGroup="regForm">
    > </asp:Button>
    >
    > <asp:ObjectDataSource ID="odsRegistrant" runat="server"
    > TypeName="RegistrantDB" SelectMethod="GetRegistrant"
    > UpdateMethod="UpdateRegistrant" DataObjectTypeName="RegistrantDetails"
    > ConvertNullToDBNull="true">
    > <SelectParameters>
    > <asp:SessionParameter DefaultValue="60" Name="registrantId"
    > SessionField="RegistrantId"
    > Type="Int32" />
    > </SelectParameters>
    > <UpdateParameters>
    > <asp:parameter Name="firstName" Type="String" />
    > <asp:parameter Name="mI" Type="String" />
    > <asp:parameter Name="lastName" Type="String" />
    > <asp:parameter Name="eMail" Type="String" />
    > ...
    >
    > My TypeName has:
    > public void UpdateRegistrant( RegistrantDetails reg ) {
    > SqlConnection con = new SqlConnection( connectionString );
    > SqlCommand cmd = new SqlCommand( "UpdateRegistrant", con );
    > cmd.CommandType = CommandType.StoredProcedure;
    > cmd.Parameters.Add( new SqlParameter( "@FirstName", SqlDbType.NVarChar,
    > 25 ) );
    > cmd.Parameters["@FirstName"].Value = reg.FirstName == null ? "" :
    > reg.FirstName;
    > ...
    >
    > And my DataObjectTypeName has:
    > public RegistrantDetails(){}
    > protected string firstName = String.Empty;
    > public string FirstName
    > {
    > get {return firstName;}
    > set {if (value != null){firstName = value;}}
    > }
    > ...
    >
    > Thanks for any clues as to what I must have missed. No exceptions are
    > generated and debugger shows the set and update methods aren't invoked.
    >
    > Thanks much.
    =?Utf-8?B?RGFiYmxlcg==?=, Apr 13, 2006
    #2
    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. Fred Dag
    Replies:
    0
    Views:
    1,678
    Fred Dag
    Sep 18, 2006
  2. kidders
    Replies:
    0
    Views:
    584
    kidders
    Jan 23, 2007
  3. Larry Bud

    Formview update--one field won't update

    Larry Bud, Jul 11, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    388
    Larry Bud
    Jul 11, 2007
  4. Replies:
    1
    Views:
    365
  5. Aamir Ghanchi

    Formview and ObjectDataSource Update method

    Aamir Ghanchi, Jan 7, 2008, in forum: ASP .Net
    Replies:
    3
    Views:
    1,182
    Phil H
    Feb 5, 2008
Loading...

Share This Page