0

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!

2
Contributors
3
Replies
21
Views
3 Years
Discussion Span
Last Post by Daemon_CC
0

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.

Edited by Daemon_CC: update

0

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 :(

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.