Here's my formview..

<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="recid">
    <EditItemTemplate>
        RECID:
        <asp:TextBox ID="recid" runat="server" Text='<%# Eval("RECID") %>' ReadOnly="true" />                            
        <br />
        SHIPPER:
        <asp:TextBox ID="shipper" runat="server" Text='<%# Bind("SHIPPER") %>' />
        <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>
</asp:FormView>

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" >

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

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

    </asp:SqlDataSource>  

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?

Thanks!

you can try

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

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

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

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

but still it treats @recid as string :(

try to put Type="Integer" instead of Type="Int32"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.