P
paulbradleysmith
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
etailsView 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
First Name
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
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
<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
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:TableCell>
<asp:TableCell>
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
etailsView>
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
arameter Name="Original_ParticipantID"
Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp
arameter Name="Title" Type="String" />
<asp
arameter Name="FirstName" Type="String" />
<asp
arameter Name="MiddleName" Type="String" />
<asp
arameter Name="LastName" Type="String" />
<asp
arameter Name="Position" Type="String" />
<asp
arameter Name="Department" Type="String" />
<asp
arameter Name="InstitutionalAffiliation"
Type="String" />
<asp
arameter Name="Email" Type="String" />
<asp
arameter Name="Address1" Type="String" />
<asp
arameter Name="Address2" Type="String" />
<asp
arameter Name="City" Type="String" />
<asp
arameter Name="StateProv" Type="String" />
<asp
arameter Name="PostalCode" Type="String" />
<asp
arameter Name="Country" Type="String" />
<asp
arameter Name="Phone" Type="String" />
<asp
arameter Name="Fax" Type="String" />
<asp
arameter Name="Added" Type="DateTime" />
<asp
arameter Name="Modified" Type="DateTime" />
<asp
arameter Name="Username" Type="String" />
<asp
arameter Name="MembershipSectionIndividual"
Type="String" />
<asp
arameter Name="MembershipCategory"
Type="String" />
<asp
arameter Name="MembershipCurrent"
Type="Boolean" />
<asp
arameter Name="AccountStatus" Type="String" />
<asp
arameter Name="HasSignedIn" Type="Boolean" />
<asp
arameter Name="AltEmail1" Type="String" />
<asp
arameter Name="AltEmail2" Type="String" />
<asp
arameter Name="Original_ParticipantID"
Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="lbParticipantList"
Name="MyParticipantID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp
arameter Name="Title" Type="String" />
<asp
arameter Name="FirstName" Type="String" />
<asp
arameter Name="MiddleName" Type="String" />
<asp
arameter Name="LastName" Type="String" />
<asp
arameter Name="Position" Type="String" />
<asp
arameter Name="Department" Type="String" />
<asp
arameter Name="InstitutionalAffiliation"
Type="String" />
<asp
arameter Name="Email" Type="String" />
<asp
arameter Name="Address1" Type="String" />
<asp
arameter Name="Address2" Type="String" />
<asp
arameter Name="City" Type="String" />
<asp
arameter Name="StateProv" Type="String" />
<asp
arameter Name="PostalCode" Type="String" />
<asp
arameter Name="Country" Type="String" />
<asp
arameter Name="Phone" Type="String" />
<asp
arameter Name="Fax" Type="String" />
<asp
arameter Name="Added" Type="DateTime" />
<asp
arameter Name="Modified" Type="DateTime" />
<asp
arameter Name="Username" Type="String" />
<asp
arameter Name="MembershipSectionIndividual"
Type="String" />
<asp
arameter Name="MembershipCategory"
Type="String" />
<asp
arameter Name="MembershipCurrent"
Type="Boolean" />
<asp
arameter Name="AccountStatus" Type="String" />
<asp
arameter Name="HasSignedIn" Type="Boolean" />
<asp
arameter Name="AltEmail1" Type="String" />
<asp
arameter Name="AltEmail2" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
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
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
First Name
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
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
E-mail<br />runat='server' ID='Email' Width='300px' Text=' said:<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
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>
Phone<br />
</
asp:TableCell>
<asp:TableCell>
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
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
Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp
<asp
<asp
<asp
<asp
<asp
<asp
Type="String" />
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
Type="String" />
<asp
Type="String" />
<asp
Type="Boolean" />
<asp
<asp
<asp
<asp
<asp
Type="Int32" />
</UpdateParameters>
<SelectParameters>
<asp:ControlParameter ControlID="lbParticipantList"
Name="MyParticipantID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp
<asp
<asp
<asp
<asp
<asp
<asp
Type="String" />
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
<asp
Type="String" />
<asp
Type="String" />
<asp
Type="Boolean" />
<asp
<asp
<asp
<asp
</InsertParameters>
</asp:ObjectDataSource>