I have a details view as follows:
With the datasource:
When i click on update and make a change it doesn't update the database. Anyone know why?
Thanks
Code:
<asp:DetailsView ID="dvMyDetails" runat="server" AutoGenerateRows="False"
DataKeyNames="ParentID" DataSourceID="GetMyDetails" Height="50px" Width="500px" CssClass="padded-table" >
<Fields>
<asp:BoundField DataField="ParentID" HeaderText="ParentID"
InsertVisible="False" ReadOnly="True" SortExpression="ParentID" />
<asp:BoundField DataField="Firstname" HeaderText="Firstname"
SortExpression="Firstname" ControlStyle-Width="290px" ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="Surname" HeaderText="Surname"
SortExpression="Surname" ControlStyle-Width="290px" ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="EmailAddress" HeaderText="EmailAddress"
SortExpression="EmailAddress" ControlStyle-Width="290px"
ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="AddressLine1" HeaderText="AddressLine1"
SortExpression="AddressLine1" ControlStyle-Width="290px"
ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="AddressLine2" HeaderText="AddressLine2"
SortExpression="AddressLine2" ControlStyle-Width="290px"
ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="AddressLine3" HeaderText="AddressLine3"
SortExpression="AddressLine3" ControlStyle-Width="290px"
ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="AddressLine4" HeaderText="AddressLine4"
SortExpression="AddressLine4" ControlStyle-Width="290px"
ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="Town" HeaderText="Town" SortExpression="Town" ControlStyle-Width="290px" ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="Postcode" HeaderText="Postcode"
SortExpression="Postcode" ControlStyle-Width="290px" ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="ContactPhone" HeaderText="ContactPhone"
SortExpression="ContactPhone" ControlStyle-Width="290px"
ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="NumberofKids" HeaderText="NumberofKids"
SortExpression="NumberofKids" ControlStyle-Width="290px"
ControlStyle-Height="25px" ControlStyle-CssClass="enquiryfield" />
<asp:BoundField DataField="DateRegistered" HeaderText="DateRegistered"
SortExpression="DateRegistered" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
With the datasource:
Code:
<asp:SqlDataSource ID="GetMyDetails" runat="server"
ConnectionString="<%$ ConnectionStrings:quickbabysitConnectionString %>"
DeleteCommand="DELETE FROM [Parents] WHERE [ParentID] = @ParentID"
InsertCommand="INSERT INTO [Parents] ([Firstname], [Surname], [EmailAddress], [AddressLine1], [AddressLine2], [AddressLine3], [AddressLine4], [Town], [Postcode], [ContactPhone], [NumberofKids], [DateRegistered]) VALUES (@Firstname, @Surname, @EmailAddress, @AddressLine1, @AddressLine2, @AddressLine3, @AddressLine4, @Town, @Postcode, @ContactPhone, @NumberofKids, @DateRegistered)"
SelectCommand="SELECT [ParentID], [Firstname], [Surname], [EmailAddress], [AddressLine1], [AddressLine2], [AddressLine3], [AddressLine4], [Town], [Postcode], [ContactPhone], [NumberofKids], [DateRegistered] FROM [Parents] WHERE ([ParentID] = @ParentID)"
UpdateCommand="UPDATE [Parents] SET [Firstname] = @Firstname, [Surname] = @Surname, [EmailAddress] = @EmailAddress, [AddressLine1] = @AddressLine1, [AddressLine2] = @AddressLine2, [AddressLine3] = @AddressLine3, [AddressLine4] = @AddressLine4, [Town] = @Town, [Postcode] = @Postcode, [ContactPhone] = @ContactPhone, [NumberofKids] = @NumberofKids, [DateRegistered] = @DateRegistered WHERE [ParentID] = @ParentID">
<DeleteParameters>
<asp:Parameter Name="ParentID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Firstname" Type="String" />
<asp:Parameter Name="Surname" Type="String" />
<asp:Parameter Name="EmailAddress" Type="String" />
<asp:Parameter Name="AddressLine1" Type="String" />
<asp:Parameter Name="AddressLine2" Type="String" />
<asp:Parameter Name="AddressLine3" Type="String" />
<asp:Parameter Name="AddressLine4" Type="String" />
<asp:Parameter Name="Town" Type="String" />
<asp:Parameter Name="Postcode" Type="String" />
<asp:Parameter Name="ContactPhone" Type="String" />
<asp:Parameter Name="NumberofKids" Type="Decimal" />
<asp:Parameter Name="DateRegistered" Type="DateTime" />
</InsertParameters>
<SelectParameters>
<asp:ControlParameter ControlID="HiddenParentID" Name="ParentID"
PropertyName="Value" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="Firstname" Type="String" />
<asp:Parameter Name="Surname" Type="String" />
<asp:Parameter Name="EmailAddress" Type="String" />
<asp:Parameter Name="AddressLine1" Type="String" />
<asp:Parameter Name="AddressLine2" Type="String" />
<asp:Parameter Name="AddressLine3" Type="String" />
<asp:Parameter Name="AddressLine4" Type="String" />
<asp:Parameter Name="Town" Type="String" />
<asp:Parameter Name="Postcode" Type="String" />
<asp:Parameter Name="ContactPhone" Type="String" />
<asp:Parameter Name="NumberofKids" Type="Decimal" />
<asp:Parameter Name="DateRegistered" Type="DateTime" />
<asp:Parameter Name="ParentID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
When i click on update and make a change it doesn't update the database. Anyone know why?
Thanks