locked
DetailsView Does Nothing When Updating... RRS feed

  • Question

  • User669123078 posted

    Trying to add a simple edit function to this detailsview control but it wont work... it allows you to click edit and enter information, but when clicking update it just does nothing... any ideas?

    Details view code...

    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="669px"
        AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="SqlDataSource1"
        CellPadding="2" GridLines="None" CellSpacing="2">
        <Fields>
            <asp:CommandField ShowEditButton="True" EditText="Edit Details" UpdateText="Save">
            </asp:CommandField>
            <asp:BoundField HeaderText="Product Details" ReadOnly="True">
            <HeaderStyle BackColor="#0066FF" Font-Bold="True" ForeColor="White" Width="250px"/>
            <ItemStyle BackColor="#0066FF" />
            </asp:BoundField>
            <asp:BoundField DataField="ProductType" HeaderText="Product Type:"
                SortExpression="ProductType" ReadOnly="True">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="PurchaseDate" HeaderText="Purchased Date/Time:"
                SortExpression="PurchaseDate" ReadOnly="True">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="EffectiveDate" HeaderText="Effective Date:"
                SortExpression="EffectiveDate" DataFormatString="{0:d}" ReadOnly="True">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="PremCharge" HeaderText="Premium Charged To Client Inc. IPT:"
                SortExpression="PremCharge" DataFormatString="{0:c}" ReadOnly="True">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="BreakdownCover" HeaderText="Motor Breakdown:"
                SortExpression="BreakdownCover" ReadOnly="True">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="TotalOwedToHBB" HeaderText="Total Owed To HBB:"
                SortExpression="TotalOwedToHBB" DataFormatString="{0:c}" ReadOnly="True">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField HeaderText="Client Details" ReadOnly="True">
            <HeaderStyle BackColor="#0066FF" Font-Bold="True" ForeColor="White" Width="250px"/>
            <ItemStyle BackColor="#0066FF" />
            </asp:BoundField>
            <asp:BoundField DataField="Title" HeaderText="Title"
                SortExpression="Title" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="Firstname" HeaderText="Firstname:"
                SortExpression="Firstname" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="Surname" HeaderText="Surname:"
                SortExpression="Surname" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="HouseNo" HeaderText="House Number:"
                SortExpression="HouseNo" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="Address" HeaderText="Address Line 1:"
                SortExpression="Address" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="Address2" HeaderText="Address Line 2:"
                SortExpression="Address2" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="Address3" HeaderText="Address Line 3:"
                SortExpression="Address3" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="Town" HeaderText="Address Line 4:"
                SortExpression="Town" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="Postcode" HeaderText="Postcode:"
                SortExpression="Postcode" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="CliEmail" HeaderText="Email Address:"
                SortExpression="CliEmail" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="CliTelNo" HeaderText="Telephone Number:"
                SortExpression="CliTelNo" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField HeaderText="Vehicle Details" ReadOnly="True">
            <HeaderStyle BackColor="#0066FF" Font-Bold="True" ForeColor="White" Width="250px"/>
            <ItemStyle BackColor="#0066FF" />
            </asp:BoundField>
            <asp:BoundField DataField="RegNo" HeaderText="Reg Number:" SortExpression="RegNo" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="VehicleMake" HeaderText="Vehicle Make:"
                SortExpression="VehicleMake" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="VehicleModel" HeaderText="Vehicle Model:"
                SortExpression="VehicleModel" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
            <asp:BoundField DataField="YearVehiclePurchased" HeaderText="Year Vehicle First Purchased:"
                SortExpression="YearVehiclePurchased" ReadOnly="False">
            <HeaderStyle Font-Bold="True" Width="250px"/>
            </asp:BoundField>
        </Fields>
    <AlternatingRowStyle BackColor="#E5E5E5" />
    </asp:DetailsView>

    Sqldatasource code...

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>"
        SelectCommand="SELECT * FROM [PurchaseProduct] WHERE (Id = @Id)"
        UpdateCommand="UPDATE [PurchaseProduct] SET [Firstname] = @Firstname, [Surname] = @Surname, [RegNo] =@RegNo, [Title] = @Title, [HouseNo] = @HouseNo, [Address] = @Address, [Address2] = @Address2, [Address3] =@ Address3, [Town] = @Town, [Postcode] = @Postcode, [VehicleModel] = @VehicleModel, [VehicleMake] = @VehicleMake, [YearVehiclePurchased] = @YearVehiclePurchased, [CliEmail] = @CliEmail, [CliTelNo] = @CliTelNo Where [Id] = @Id">
        <SelectParameters>
        <asp:QueryStringParameter Name="Id" QueryStringField="Id" />
        </SelectParameters>
        <UpdateParameters>
        <asp:Parameter Name="Firstname" Type="String"/>
        <asp:Parameter Name="Surname" Type="String"/>
        <asp:Parameter Name="RegNo" Type="String"/>
        <asp:Parameter Name="Title" Type="String"/>
        <asp:Parameter Name="HouseNo" Type="String"/>
        <asp:Parameter Name="Address" Type="String"/>
        <asp:Parameter Name="Address2" Type="String"/>
        <asp:Parameter Name="Address3" Type="String"/>
        <asp:Parameter Name="Town" Type="String"/>
        <asp:Parameter Name="Postcode" Type="String"/>
        <asp:Parameter Name="VehicleModel" Type="String"/>
        <asp:Parameter Name="VehicleMake" Type="String"/>
        <asp:Parameter Name="YearVehiclePurchased" Type="String"/>
        <asp:Parameter Name="CliEmail" Type="String"/>
        <asp:Parameter Name="CliTelNo" Type="String"/>
        </UpdateParameters>
    </asp:SqlDataSource>

    Monday, November 22, 2010 10:10 AM

Answers

  • User669123078 posted

    solved...  [Address3] =@ Address3 - should be [Address3] = @Address3

    seems to have fixed it ;)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 22, 2010 1:27 PM