Here's my formview..

<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="recid">
        <asp:TextBox ID="recid" runat="server" Text='<%# Eval("RECID") %>' ReadOnly="true" />                            
        <br />
        <asp:TextBox ID="shipper" runat="server" Text='<%# Bind("SHIPPER") %>' />
        <br />
        <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" />
        <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />

here's my sqldatasource1

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
        SelectCommand="SELECT * FROM IMPORT WHERE (RECID = ?)" 
        UpdateCommand="UPDATE IMPORT SET SHIPPER=@shipper WHERE RECID=@recid" >

            <asp:ControlParameter ControlID="Label1" Name="RECID" PropertyName="Text" Type="Int32" />

            <asp:Parameter Name="recid" Type="Int32" />            
            <asp:Parameter Name="shipper" Type="String" />


Now, my problem is that everytime I update the page, this is the error Input string was not in a correct format.

I tried changing the @recid in the UpdateCommand into a constant UpdateCommand="UPDATE IMPORT SET SHIPPER=@shipper WHERE RECID=11186" this worked well, the update was successful.

I think the @recid is being treated as a string here in the UpdateCommand. Can someone please help me? What do I need to do in order to change the data type of @recid to Integer?


3 Years
Discussion Span
Last Post by Daemon_CC

you can try

     <asp:ControlParameter ControlID="Label1" Name="RECID" PropertyName="integer" Type="Int32" />

this may be due to you are passing integer and you have mentioned its property value as Text.

Edited by Daemon_CC: update


hi! the select parameters are doing well, the problem is with the update thing. And I think in the update parameters. I need to tell the update command that @recid is integer in type hence having this update parameters code

            <asp:Parameter Name="recid" Type="Int32" />            
            <asp:Parameter Name="shipper" Type="String" />

but still it treats @recid as string :(

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.