C#: No value given for one or more required parameter with FormView

Posted by Vinzcent on Stack Overflow See other posts from Stack Overflow or by Vinzcent
Published on 2010-05-04T19:05:00Z Indexed on 2010/05/04 19:08 UTC
Read the original article Hit count: 385

Filed under:

Hey,

I am using a FormView and when I want to update something I have edited, I always get this error:

No value given for one or more required parameters.

I use a SQLDataSource in combination with a FormView

This is the code of my SQLDataSource

<asp:SqlDataSource ID="sqldsLokaalPrinters" runat="server" 
        ConnectionString="<%$ ConnectionStrings:connRand2 %>" 
        DeleteCommand="DELETE FROM [tblComputers] WHERE (([tblArtveldenr] = ?) OR ([tblArtveldenr] IS NULL AND ? IS NULL))" 
        InsertCommand="INSERT INTO [tblComputers] ([tblArtveldenr], [tblNaam], [tblCLokaal_id], [tblPositie], [tblSerienr], [tblTCPIP], [tblFabrikant], [tblModel], [tblProcessor], [tblSnelheid], [tblKleur], [tblGeheugen], [tblHarddisk], [tblZip], [tblCD], [tblDVD], [tblNetwerk], [tblFirewire], [tblAanschafdatum], [tblCLeverabcierNr], [tblScherm], [tblLaptop]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" 
        ProviderName="<%$ ConnectionStrings:connRand2.ProviderName %>" 
        SelectCommand="SELECT * FROM [tblComputers] WHERE ([tblCLokaal_id] = ?)" 
        UpdateCommand="UPDATE [tblComputers] SET [tblNaam] = ?, [tblCLokaal_id] = ?, [tblPositie] = ?, [tblSerienr] = ?, [tblTCPIP] = ?, [tblFabrikant] = ?, [tblModel] = ?, [tblProcessor] = ?, [tblSnelheid] = ?, [tblKleur] = ?, [tblGeheugen] = ?, [tblHarddisk] = ?, [tblZip] = ?, [tblCD] = ?, [tblDVD] = ?, [tblNetwerk] = ?, [tblFirewire] = ?, [tblAanschafdatum] = ?, [tblCLeverabcierNr] = ?, [tblScherm] = ?, [tblLaptop] = ? WHERE (([tblArtveldenr] = ?) OR ([tblArtveldenr] IS NULL AND ? IS NULL))">
        <SelectParameters>
            <asp:SessionParameter Name="tblCLokaal_id" SessionField="lokaalID" 
                Type="Int16" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="tblArtveldenr" Type="String" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="tblNaam" Type="String" />
            <asp:Parameter Name="tblCLokaal_id" Type="Int16" />
            <asp:Parameter Name="tblPositie" Type="Int32" />
            <asp:Parameter Name="tblSerienr" Type="String" />
            <asp:Parameter Name="tblTCPIP" Type="String" />
            <asp:Parameter Name="tblFabrikant" Type="String" />
            <asp:Parameter Name="tblModel" Type="String" />
            <asp:Parameter Name="tblProcessor" Type="String" />
            <asp:Parameter Name="tblSnelheid" Type="Int32" />
            <asp:Parameter Name="tblKleur" Type="String" />
            <asp:Parameter Name="tblGeheugen" Type="Int32" />
            <asp:Parameter Name="tblHarddisk" Type="Double" />
            <asp:Parameter Name="tblZip" Type="String" />
            <asp:Parameter Name="tblCD" Type="String" />
            <asp:Parameter Name="tblDVD" Type="String" />
            <asp:Parameter Name="tblNetwerk" Type="String" />
            <asp:Parameter Name="tblFirewire" Type="Int32" />
            <asp:Parameter Name="tblAanschafdatum" Type="DateTime" />
            <asp:Parameter Name="tblCLeverabcierNr" Type="Int32" />
            <asp:Parameter Name="tblScherm" Type="String" />
            <asp:Parameter Name="tblLaptop" Type="Boolean" />
            <asp:Parameter Name="tblArtveldenr" Type="String" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="tblArtveldenr" Type="String" />
            <asp:Parameter Name="tblNaam" Type="String" />
            <asp:Parameter Name="tblCLokaal_id" Type="Int16" />
            <asp:Parameter Name="tblPositie" Type="Int32" />
            <asp:Parameter Name="tblSerienr" Type="String" />
            <asp:Parameter Name="tblTCPIP" Type="String" />
            <asp:Parameter Name="tblFabrikant" Type="String" />
            <asp:Parameter Name="tblModel" Type="String" />
            <asp:Parameter Name="tblProcessor" Type="String" />
            <asp:Parameter Name="tblSnelheid" Type="Int32" />
            <asp:Parameter Name="tblKleur" Type="String" />
            <asp:Parameter Name="tblGeheugen" Type="Int32" />
            <asp:Parameter Name="tblHarddisk" Type="Double" />
            <asp:Parameter Name="tblZip" Type="String" />
            <asp:Parameter Name="tblCD" Type="String" />
            <asp:Parameter Name="tblDVD" Type="String" />
            <asp:Parameter Name="tblNetwerk" Type="String" />
            <asp:Parameter Name="tblFirewire" Type="Int32" />
            <asp:Parameter Name="tblAanschafdatum" Type="DateTime" />
            <asp:Parameter Name="tblCLeverabcierNr" Type="Int32" />
            <asp:Parameter Name="tblScherm" Type="String" />
            <asp:Parameter Name="tblLaptop" Type="Boolean" />
        </InsertParameters>
    </asp:SqlDataSource>

This is the code of my FormView

<asp:FormView ID="FormView1" runat="server" AllowPaging="True" 
        DataKeyNames="tblArtveldenr" DataSourceID="sqldsLokaalPrinters">
        <EditItemTemplate>
            tblPositie:
            <asp:TextBox ID="tblPositieTextBox" runat="server" 
                Text='<%# Bind("tblPositie") %>' />
            <br />
            tblSerienr:
            <asp:TextBox ID="tblSerienrTextBox" runat="server" 
                Text='<%# Bind("tblSerienr") %>' />
            <br />
            tblFabrikant:
            <asp:TextBox ID="tblFabrikantTextBox" runat="server" 
                Text='<%# Bind("tblFabrikant") %>' />
            <br />
            tblModel:
            <asp:TextBox ID="tblModelTextBox" runat="server" 
                Text='<%# Bind("tblModel") %>' />
            <br />
            tblSnelheid:
            <asp:TextBox ID="tblSnelheidTextBox" runat="server" 
                Text='<%# Bind("tblSnelheid") %>' />
            <br />
            tblHarddisk:
            <asp:TextBox ID="tblHarddiskTextBox" runat="server" 
                Text='<%# Bind("tblHarddisk") %>' />
            <br />
            tblCD:
            <asp:TextBox ID="tblCDTextBox" runat="server" Text='<%# Bind("tblCD") %>' />
            <br />
            tblDVD:
            <asp:TextBox ID="tblDVDTextBox" runat="server" Text='<%# Bind("tblDVD") %>' />
            <br />
            tblAanschafdatum:
            <asp:TextBox ID="tblAanschafdatumTextBox" runat="server" 
                Text='<%# Bind("tblAanschafdatum") %>' />
            <br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" 
                CommandName="Update" Text="Update" />
            &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" 
                CausesValidation="False" CommandName="Cancel" Text="Cancel" />
        </EditItemTemplate>
        <InsertItemTemplate>
            tblPositie:
            <asp:TextBox ID="tblPositieTextBox" runat="server" 
                Text='<%# Bind("tblPositie") %>' />
            <br />
            tblSerienr:
            <asp:TextBox ID="tblSerienrTextBox" runat="server" 
                Text='<%# Bind("tblSerienr") %>' />
            <br />
            tblFabrikant:
            <asp:TextBox ID="tblFabrikantTextBox" runat="server" 
                Text='<%# Bind("tblFabrikant") %>' />
            <br />
            tblModel:
            <asp:TextBox ID="tblModelTextBox" runat="server" 
                Text='<%# Bind("tblModel") %>' />
            <br />
            tblSnelheid:
            <asp:TextBox ID="tblSnelheidTextBox" runat="server" 
                Text='<%# Bind("tblSnelheid") %>' />
            <br />
            tblHarddisk:
            <asp:TextBox ID="tblHarddiskTextBox" runat="server" 
                Text='<%# Bind("tblHarddisk") %>' />
            <br />
            tblCD:
            <asp:TextBox ID="tblCDTextBox" runat="server" Text='<%# Bind("tblCD") %>' />
            <br />
            tblDVD:
            <asp:TextBox ID="tblDVDTextBox" runat="server" Text='<%# Bind("tblDVD") %>' />
            <br />
            tblAanschafdatum:
            <asp:TextBox ID="tblAanschafdatumTextBox" runat="server" 
                Text='<%# Bind("tblAanschafdatum") %>' />
            <br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" 
                CommandName="Insert" Text="Insert" />
&nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" 
                CommandName="Cancel" Text="Cancel" />
        </InsertItemTemplate>
        <ItemTemplate>
            tblPositie:
            <asp:Label ID="tblPositieLabel" runat="server" 
                Text='<%# Bind("tblPositie") %>' />
            <br />
            tblSerienr:
            <asp:Label ID="tblSerienrLabel" runat="server" 
                Text='<%# Bind("tblSerienr") %>' />
            <br />
            tblFabrikant:
            <asp:Label ID="tblFabrikantLabel" runat="server" 
                Text='<%# Bind("tblFabrikant") %>' />
            <br />
            tblModel:
            <asp:Label ID="tblModelLabel" runat="server" Text='<%# Bind("tblModel") %>' />
            <br />
            tblSnelheid:
            <asp:Label ID="tblSnelheidLabel" runat="server" 
                Text='<%# Bind("tblSnelheid") %>' />
            <br />
            tblHarddisk:
            <asp:Label ID="tblHarddiskLabel" runat="server" 
                Text='<%# Bind("tblHarddisk") %>' />
            <br />
            tblCD:
            <asp:Label ID="tblCDLabel" runat="server" Text='<%# Bind("tblCD") %>' />
            <br />
            tblDVD:
            <asp:Label ID="tblDVDLabel" runat="server" Text='<%# Bind("tblDVD") %>' />
            <br />
            tblAanschafdatum:
            <asp:Label ID="tblAanschafdatumLabel" runat="server" 
                Text='<%# Bind("tblAanschafdatum") %>' />
            <br />
            <br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" 
                CommandName="Edit" Text="Edit" />
            &nbsp;<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" 
                CommandName="Delete" Text="Delete" />
            &nbsp;<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" 
                CommandName="New" Text="New" />
        </ItemTemplate>
    </asp:FormView>

I have no idea how to solve this error

Thanks a lot Vincent

© Stack Overflow or respective owner

Related posts about c#