Input string was not in a correct format asp.net c#
<p>I have a Grid and it is displaying users this is working. You can click on Edit (Image Button) or on a Delete (Image Button) to do the action . But if I click on on of these I get a </p>

<blockquote>
  <p>Input string was not in a correct format</p>
</blockquote>

<p>This should not happen -- I don't see my error. What is the problem?</p>

<p>Here is my grid: </p>

<pre><code>&lt;asp:EntityDataSource ID="EntityDataSource1" runat="server"
    ConnectionString="name=HolidayTrackerEntities"
    DefaultContainerName="HolidayTrackerEntities" EnableFlattening="False"
    EntitySetName="HtUsers"&gt;
&lt;/asp:EntityDataSource&gt;
&lt;telerik:RadGrid ID="rgGrid" runat="server" DataSourceID="EntityDataSource1"
    AllowSorting="True" AllowPaging="True" PageSize="20" 
    AllowFilteringByColumn="True" ShowStatusBar="True" Width="100%" 
    CellSpacing="0" GridLines="None" OnItemCommand="rgGrid_ItemCommand"&gt;
    &lt;MasterTableView AutoGenerateColumns="False" DataKeyNames="UserId"&gt;
        &lt;NoRecordsTemplate&gt;
            Can't find Users to display
        &lt;/NoRecordsTemplate&gt;
        &lt;Columns&gt;
            &lt;telerik:GridBoundColumn DataField="UserId" DataType="System.Int32"
                FilterControlAltText="Filter UserId column" HeaderText="UserId" 
                ReadOnly="True" SortExpression="UserId" UniqueName="UserId"
                Visible="false"&gt;
            &lt;/telerik:GridBoundColumn&gt;
            &lt;telerik:GridBoundColumn DataField="FirstName"
                FilterControlAltText="Filter FirstName column"
                HeaderText="FirstName" ItemStyle-Width="60px"
                SortExpression="FirstName" UniqueName="FirstName"&gt;
                &lt;ItemStyle Width="60px" /&gt;
            &lt;/telerik:GridBoundColumn&gt;
            &lt;telerik:GridBoundColumn DataField="LastName"
                FilterControlAltText="Filter LastName column"
                HeaderText="LastName" ItemStyle-Width="60px" 
                SortExpression="LastName" UniqueName="LastName"&gt;
                &lt;ItemStyle Width="60px" /&gt;
            &lt;/telerik:GridBoundColumn&gt;
            &lt;telerik:GridBoundColumn DataField="UserName"
                FilterControlAltText="Filter UserName column"
                HeaderText="UserName" ItemStyle-Width="60px"
                SortExpression="UserName" UniqueName="UserName"&gt;
                &lt;ItemStyle Width="60px" /&gt;
            &lt;/telerik:GridBoundColumn&gt;
            &lt;telerik:GridBoundColumn DataField="Email"
                FilterControlAltText="Filter Email column"
                HeaderText="Email" SortExpression="Email" UniqueName="Email"
                Visible="False"&gt;
            &lt;/telerik:GridBoundColumn&gt;
            &lt;telerik:GridTemplateColumn UniqueName="DeleteColumn" 
                ItemStyle-HorizontalAlign="Right" ItemStyle-Width="20px"
                AllowFiltering="false"&gt;
                &lt;ItemTemplate&gt;
                    &lt;telerik:RadButton ID="btnEdit" CommandName="Edit" runat="server" Width="20px" ToolTip="View Details" Height="20px"&gt;
                        &lt;Image ImageUrl="~/Resources/Images/Grid/edit-app.png" IsBackgroundImage="true" /&gt;
                    &lt;/telerik:RadButton&gt;
                &lt;/ItemTemplate&gt;
            &lt;/telerik:GridTemplateColumn&gt;
            &lt;telerik:GridTemplateColumn UniqueName="Delete"
                ItemStyle-HorizontalAlign="Right" ItemStyle-Width="20px"
                AllowFiltering="false" FilterImageUrl="../Image/Filter.gif"&gt;
                &lt;ItemTemplate&gt;
                    &lt;telerik:RadButton ID="btnDelete" CommandName="Delete" runat="server" Width="20px" ToolTip="Delte User" Height="20px"&gt;
                        &lt;Image ImageUrl="~/Resources/Images/Grid/delete-app.png" IsBackgroundImage="true" /&gt;
                    &lt;/telerik:RadButton&gt;
                &lt;/ItemTemplate&gt;
            &lt;/telerik:GridTemplateColumn&gt;
        &lt;/Columns&gt;
    &lt;/MasterTableView&gt;
&lt;/telerik:RadGrid&gt;
</code></pre>

<p>As I said nothing special. Here are the buttons in code behind:</p>

<pre><code>protected void rgGrid_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName.Equals("Edit"))
    {
        int id = int.Parse(e.Item.Cells[2].Text);
        Response.Redirect("~/Administrator/UserEditPanel.aspx?userId=" + id);
    }
    else if (e.CommandName.Equals("Delete"))
    {
        int id = int.Parse(e.Item.Cells[2].Text);
        HtUser.DeleteUserById(id);
    }
}
</code></pre>

<p>My Delete Function in the User class </p>

<pre><code>public static void DeleteUserById(int id)
{
    HolidayTrackerEntities ctx = HtEntityFactory.Context;
    HtUser userToDelete = ctx.HtUsers.Where(user =&gt; user.UserId == id).FirstOrDefault();

    //Get all the userroles where user is containing
    IEnumerable&lt;HtUserRole&gt; roles = ctx.HtUserRoles.Where(ur =&gt; ur.HtUsers.Where(x =&gt; x.UserId == id).Any());
    foreach (HtUserRole role in roles)
    {
        //Remove reference from htuserroles table
        role.HtUsers.Remove(userToDelete);
    }

    ctx.HtUsers.DeleteObject(userToDelete);
    ctx.SaveChanges();
}
</code></pre>
