Input string was not in a correct format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bart

    Input string was not in a correct format

    Hi,

    i defined a linkbutton in a gridview. In code-behind, i want to perform the
    delete query when the user clicks on the linkbutton, but this code gives
    following error:
    "Input string was not in a correct format." at line: r =
    Convert.ToInt16 (e.CommandArgum ent)

    Thanks for help
    Bart


    aspx file:
    --------
    <asp:GridView ID="GridView1" runat="server" />
    <Columns>
    <asp:TemplateFi eld>
    <ItemTemplate >
    <asp:LinkButt on ID="lb1" runat="server" CommandName="De lete"
    Text="delete"
    OnClientClick=" return confirm('Cancel ?');" >
    </asp:LinkButton>
    </ItemTemplate>
    </asp:TemplateFie ld>
    ....

    code-behind:
    -------------
    Protected Sub GridView1_RowCo mmand(ByVal sender As Object, ByVal e As
    System.Web.UI.W ebControls.Grid ViewCommandEven tArgs) Handles
    GridView1.RowCo mmand
    Dim r As Int16
    Select Case e.CommandName
    Case "Delete"
    r = Convert.ToInt16 (e.CommandArgum ent)
    Me.GridView1.De leteRow(r)
    End Select
    End Sub


Working...