troubleshooting Question

Cannot get update button to work in edit view on detailsview

Avatar of dkpepsict
dkpepsict asked on
.NET ProgrammingASP.NETVisual Basic.NET
6 Comments1 Solution475 ViewsLast Modified:
Hello,

I have a problem with this ASP.NET code:
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master"
    CodeBehind="CustomerDetails.aspx.vb" Inherits="RedningkorpsDanmarkCRM.CustomerDetails" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Kunde detaljer
    </h2>
    <br />
    &nbsp;test
<asp:DetailsView ID="KundeCoreInfoDetails" runat="server" 
    DataSourceID="tbl_KunderDetailsForm" Height="50px" Width="100%" 
        AutoGenerateRows="False" BackColor="White" BorderColor="#CCCCCC" 
        BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" 
        GridLines="Horizontal" AutoGenerateEditButton="True" DataKeyNames="TranID">
    <EditRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
    <Fields>
        <asp:BoundField DataField="TranID" HeaderText="Kunde nummer" 
            SortExpression="TranID" ReadOnly="True" />
        <asp:BoundField DataField="Fornavn" HeaderText="Fornavn" 
            SortExpression="Fornavn" />
        <asp:BoundField DataField="Efternavn" HeaderText="Efternavn" 
            SortExpression="Efternavn" />
        <asp:BoundField DataField="Adresse" HeaderText="Adresse" 
            SortExpression="Adresse" />
        <asp:BoundField DataField="By" HeaderText="By" SortExpression="By" />
        <asp:BoundField DataField="Postnummer" HeaderText="Postnummer" 
            SortExpression="Postnummer" />
        <asp:BoundField DataField="Primært_tlf" HeaderText="Primært_tlf" 
            SortExpression="Primært_tlf" />
        <asp:BoundField DataField="Andet_tlf" HeaderText="Andet_tlf" 
            SortExpression="Andet_tlf" />
        <asp:BoundField DataField="E-mail" HeaderText="E-Mail" 
            SortExpression="email" />
        <asp:BoundField DataField="Læst_Betingelser" HeaderText="Læst_Betingelser" 
            SortExpression="Læst_Betingelser" />
        <asp:BoundField DataField="autohjælp_idag" HeaderText="autohjælp_idag" 
            SortExpression="autohjælp_idag" />
        <asp:BoundField DataField="Opsige_nuværende_aftale" 
            HeaderText="Opsige_nuværende_aftale" SortExpression="Opsige_nuværende_aftale" />
        <asp:BoundField DataField="nuværende_abonnr_fra_gamle" 
            HeaderText="nuværende_abonnr_fra_gamle" 
            SortExpression="nuværende_abonnr_fra_gamle" />
        <asp:BoundField DataField="Bemærkninger_til_min_bestilling" 
            HeaderText="Bemærkninger_til_min_bestilling" 
            SortExpression="Bemærkninger_til_min_bestilling" />
        <asp:BoundField DataField="Rabatkode" HeaderText="Rabatkode" 
            SortExpression="Rabatkode" />
    </Fields>
    
    <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
    <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
</asp:DetailsView>
    <asp:SqlDataSource ID="tbl_KunderDetailsForm" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CRMDBConnectionString %>" 
        SelectCommand="SELECT [TranID], [Fornavn], [Efternavn], [Adresse], [By], [Postnummer], [Primært_tlf], [Andet_tlf], [e-mail], [Læst_Betingelser], [autohjælp_idag], [Opsige_nuværende_aftale], [nuværende_abonnr_fra_gamle], [Bemærkninger_til_min_bestilling], [Rabatkode] FROM [tbl_Kunder] WHERE ([TranID] = @TranID)"
        UpdateCommand="UPDATE [tbl_Kunder] SET [Fornavn]=@Fornavn, [Efternavn]=@Efternavn, [Adresse]=@Adresse, [By]=@By, [Postnummer]=@Postnummer, [Primært_tlf]=@Primært_tlf, [Andet_tlf]=@Andet_tlf, [e-mail]=@email, [Læst_Betingelser]=@Læst_Betingelser, [autohjælp_idag]=@autohjælp_idag [Opsige_nuværende_aftale]=@Opsige_nuværende_aftale [nuværende_abonnr_fra_gamle]=@nuværende_abonnr_fra_gamle [Bemærkninger_til_min_bestilling]=@Bemærkninger_til_min_bestilling [Rabatkode]=@Rabatkode WHERE ([TranID] = @TranID)">
        <SelectParameters>
            <asp:QueryStringParameter Name="TranID" QueryStringField="TranID" 
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>

If I click in the Edit link, make a change in one of the fields, and press Update, nothing happens, but cancel works fine (send me back to read view).

In my source I have added a update command, is there anything else I am missing before update sends the changes to the sql database and changes back to read view with the update?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros