DetailsView Update command working, but it wipes out my record with null values

Discussion in 'ASP .Net Web Controls' started by paulbradleysmith@gmail.com, Apr 30, 2007.

  1. Guest

    I have a dataset that's represented by an object datasource. Said
    data source has a single parameter --- which is the primary key of
    the table. Its tied to a listbox where the user selects which record
    to edit -- and then the record details are displayed in the
    DetailsView. The DetailsView uses an EditItemTemplate and two-way
    databinding to display the record for editing. The object datasource
    appears to be properly set up and everything works slickly, except
    when you try to update a record. The update appears to work properly,
    but the entire record, excepting the primary key, is replaced with
    null values.

    Anyone run into this problem and have a suggestion? Thanks.


    Brad Smith


    --------------------------------------------------

    Here's my detailsview:

    <asp:DetailsView ID="dvParticipant" runat="server"
    AutoGenerateRows="False" DataKeyNames="ParticipantID"
    DataSourceID="objDSSelectedParticipant"
    AutoGenerateEditButton='true' DefaultMode='Edit'
    Height="50px" Width="300px"
    AutoGenerateDeleteButton='true' >
    <Fields>
    <asp:TemplateField>
    <EditItemTemplate>
    <asp:textbox id="ParticipantID"
    runat="server" Text='<%#eVAL("ParticipantID")%>' /> </br>
    Participant ID
    <asp:Table runat='server'
    CellPadding='2' CellSpacing='0' GridLines='Both' BorderWidth='3'
    BorderStyle='Ridge' Width='250px' ID='tblDV'>
    <asp:TableRow>
    <asp:TableCell>
    <asp:TextBox
    runat='server' ID='FirstName' Text='<%# Bind("FirstName") %>' /><br /
    >

    First Name
    </asp:TableCell>
    <asp:TableCell>
    <asp:TextBox
    runat='server' ID='MiddleName' Text='<%# Bind("MiddleName") %>' /><br /
    >

    Middle Name
    </asp:TableCell>
    <asp:TableCell>
    <asp:TextBox
    runat='server' ID='LastNAme' Text='<%# Bind("LastName") %>' /><br />
    Last Name
    </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
    <asp:TableCell
    ColumnSpan="3">
    <asp:TextBox
    runat='server' ID='InstitutionalAffiliation' Width='300px' Text='<%#
    Bind("InstitutionalAffiliation") %>' /><br />
    Institution
    </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
    <asp:TableCell
    ColumnSpan="3">
    <asp:TextBox
    runat='server' ID='Department' Width='300px' Text='<%#
    Bind("DEpartment") %>' /><br />
    Department
    </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
    <asp:TableCell
    ColumnSpan="3">
    <asp:TextBox
    runat='server' ID='Email' Width='300px' Text='<%# Bind("Email") %>' /
    ><br />

    E-mail<br />
    <asp:TextBox
    runat='server' ID='AltEmail1' Width='300px' Text='<%#
    Bind("AltEmail1") %>' /><br />
    Alternate E-mail
    </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
    <asp:TableCell
    ColumnSpan="3">
    <asp:TextBox
    runat='server' ID='Address1' Width='300px' Text='<%# Bind("Address1")
    %>' /><br />
    Address 1
    </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
    <asp:TableCell
    ColumnSpan="3">
    <asp:TextBox
    runat='server' ID='Address2' Width="300px" Text='<%# Bind("Address2")
    %>' /><br />
    Address 2
    </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
    <asp:TableCell>
    <asp:TextBox
    runat='server' ID='City' Text='<%# Bind("City") %>' /><br />
    City
    </asp:TableCell>
    <asp:TableCell>
    <asp:TextBox
    runat='server' ID='StateProv' Text='<%# Bind("StateProv") %>' /><br />
    State/Province
    </asp:TableCell>
    <asp:TableCell>
    <asp:TextBox
    runat='server' ID='PostalCode' Text='<%# Bind("PostalCode") %>' /><br /
    >

    Zip/Postal Code
    </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
    <asp:TableCell
    ColumnSpan="3">
    <asp:TextBox
    runat='server' ID='Country' Text='<%# Bind("Country") %>' /><br />
    Country
    </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
    <asp:TableCell
    ColumnSpan="3">
    <asp:Table
    runat='server' ID='tblPhoneFax'>
    <asp:TableRow>

    <asp:TableCell>

    <asp:TextBox runat='server' ID='Phone' Text='<%# Bind("Phone") %>' /
    ><br />

    Phone
    </
    asp:TableCell>

    <asp:TableCell>

    <asp:TextBox runat='server' ID='Fax' Text='<%# Bind("Fax") %>' /><br /
    >

    Fax
    </
    asp:TableCell></asp:TableRow>
    </asp:Table>
    </asp:TableCell>
    </asp:TableRow>
    </asp:Table>
    </EditItemTemplate>
    </asp:TemplateField>
    <asp:BoundField DataField="Title"
    HeaderText="Title" SortExpression="Title" />
    <asp:BoundField DataField="Position"
    HeaderText="Position" SortExpression="Position" />

    </Fields>
    </asp:DetailsView>





    And my object datasource:





    <asp:ObjectDataSource ID="objDSSelectedParticipant"
    runat="server" DeleteMethod="Delete"
    InsertMethod="Insert"
    OldValuesParameterFormatString="original_{0}"
    SelectMethod="GetParticipantsByID"

    TypeName="MeetingDataTableAdapters.ParticipantsTableAdapter"
    UpdateMethod="Update">
    <DeleteParameters>
    <asp:parameter Name="Original_ParticipantID"
    Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
    <asp:parameter Name="Title" Type="String" />
    <asp:parameter Name="FirstName" Type="String" />
    <asp:parameter Name="MiddleName" Type="String" />
    <asp:parameter Name="LastName" Type="String" />
    <asp:parameter Name="Position" Type="String" />
    <asp:parameter Name="Department" Type="String" />
    <asp:parameter Name="InstitutionalAffiliation"
    Type="String" />
    <asp:parameter Name="Email" Type="String" />
    <asp:parameter Name="Address1" Type="String" />
    <asp:parameter Name="Address2" Type="String" />
    <asp:parameter Name="City" Type="String" />
    <asp:parameter Name="StateProv" Type="String" />
    <asp:parameter Name="PostalCode" Type="String" />
    <asp:parameter Name="Country" Type="String" />
    <asp:parameter Name="Phone" Type="String" />
    <asp:parameter Name="Fax" Type="String" />
    <asp:parameter Name="Added" Type="DateTime" />
    <asp:parameter Name="Modified" Type="DateTime" />
    <asp:parameter Name="Username" Type="String" />
    <asp:parameter Name="Password" Type="String" />
    <asp:parameter Name="OrganizationName" Type="String" /
    >

    <asp:parameter Name="MembershipSectionIndividual"
    Type="String" />
    <asp:parameter Name="MembershipCategory"
    Type="String" />
    <asp:parameter Name="MembershipCurrent"
    Type="Boolean" />
    <asp:parameter Name="AccountStatus" Type="String" />
    <asp:parameter Name="HasSignedIn" Type="Boolean" />
    <asp:parameter Name="AltEmail1" Type="String" />
    <asp:parameter Name="AltEmail2" Type="String" />
    <asp:parameter Name="Original_ParticipantID"
    Type="Int32" />
    </UpdateParameters>
    <SelectParameters>
    <asp:ControlParameter ControlID="lbParticipantList"
    Name="MyParticipantID" PropertyName="SelectedValue"
    Type="Int32" />
    </SelectParameters>
    <InsertParameters>
    <asp:parameter Name="Title" Type="String" />
    <asp:parameter Name="FirstName" Type="String" />
    <asp:parameter Name="MiddleName" Type="String" />
    <asp:parameter Name="LastName" Type="String" />
    <asp:parameter Name="Position" Type="String" />
    <asp:parameter Name="Department" Type="String" />
    <asp:parameter Name="InstitutionalAffiliation"
    Type="String" />
    <asp:parameter Name="Email" Type="String" />
    <asp:parameter Name="Address1" Type="String" />
    <asp:parameter Name="Address2" Type="String" />
    <asp:parameter Name="City" Type="String" />
    <asp:parameter Name="StateProv" Type="String" />
    <asp:parameter Name="PostalCode" Type="String" />
    <asp:parameter Name="Country" Type="String" />
    <asp:parameter Name="Phone" Type="String" />
    <asp:parameter Name="Fax" Type="String" />
    <asp:parameter Name="Added" Type="DateTime" />
    <asp:parameter Name="Modified" Type="DateTime" />
    <asp:parameter Name="Username" Type="String" />
    <asp:parameter Name="Password" Type="String" />
    <asp:parameter Name="OrganizationName" Type="String" /
    >

    <asp:parameter Name="MembershipSectionIndividual"
    Type="String" />
    <asp:parameter Name="MembershipCategory"
    Type="String" />
    <asp:parameter Name="MembershipCurrent"
    Type="Boolean" />
    <asp:parameter Name="AccountStatus" Type="String" />
    <asp:parameter Name="HasSignedIn" Type="Boolean" />
    <asp:parameter Name="AltEmail1" Type="String" />
    <asp:parameter Name="AltEmail2" Type="String" />
    </InsertParameters>
    </asp:ObjectDataSource>
     
    , Apr 30, 2007
    #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. JT
    Replies:
    5
    Views:
    373
  2. Replies:
    1
    Views:
    616
    GArlington
    Aug 31, 2007
  3. SDA
    Replies:
    0
    Views:
    323
  4. Frits van Soldt

    How to insert a new record in detailsview when there are no record

    Frits van Soldt, Nov 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    810
    Frits van Soldt
    Nov 17, 2005
  5. PerlFAQ Server
    Replies:
    0
    Views:
    151
    PerlFAQ Server
    Apr 26, 2011
Loading...

Share This Page