title: CommandArgument Input string was not in a correct format
body: <p>When I want to read e.CommandArgument then I get error saying "Input string was not in a correct format.". My markup portion is like bellow:</p>
  
  <pre><code>&lt;asp:GridView ID="GridViewAllProducts" runat="server" 
      AutoGenerateColumns="False" GridLines="None"
               AllowPaging="True" Width="100%"
               EmptyDataText="هیچ محصولی پیدا نشد" 
              onrowcommand="GridViewAllProducts_RowCommand" 
      onrowdeleting="GridViewAllProducts_RowDeleting"
      OnPageIndexChanging="GridViewAllProducts_PageIndexChanging"&gt;
              &lt;Columns&gt;
                  &lt;asp:TemplateField&gt;
                      &lt;ItemTemplate&gt;
                          &lt;div class='rowTableDiv rowAllNewsUC'&gt;
                              &lt;asp:HiddenField ID="hiddenId" runat="server" Value='&lt;%# Bind("Id") %&gt;' /&gt;
                              &lt;img id="imgImage" src='&lt;%# Bind("Image") %&gt;' class="imgNewsAllNewsUC noBorder" alt="" runat="server" /&gt;
                              عنوان محصول:&amp;nbsp;&lt;asp:Label ID="lblTitle" runat="server" Text='&lt;%# Bind("Title") %&gt;'&gt;&lt;/asp:Label&gt;&lt;br /&gt;
                              گروه:&amp;nbsp;&lt;asp:Label ID="lblCategory" runat="server" Text='&lt;%# ProductC.GetProductCategoryName(Convert.ToInt32(Eval("CategoryId"))) %&gt;'&gt;&lt;/asp:Label&gt;&lt;br /&gt;
                              کد:&amp;nbsp;&lt;asp:Label ID="lblCode" runat="server" Text='&lt;%# Bind("Code") %&gt;'&gt;&lt;/asp:Label&gt;&lt;br /&gt;
                              ابعاد:&amp;nbsp;&lt;asp:Label ID="lblDimention" runat="server" Text='&lt;%# Bind("Dimention") %&gt;'&gt;&lt;/asp:Label&gt;&lt;br /&gt;
                              تعداد رنگ:&amp;nbsp;&lt;asp:Label ID="lblNumberOfColors" runat="server" Text='&lt;%# Bind("NumberOfColors") %&gt;'&gt;&lt;/asp:Label&gt;&lt;br /&gt;
                              قیمت:&amp;nbsp;&lt;asp:Label ID="lblPrice" runat="server" Text='&lt;%# nmsPublicClass.PublicClassC.ThousandSeparator(Convert.ToDecimal(Eval("Price"))) %&gt;'&gt;&lt;/asp:Label&gt;
                              &lt;asp:LoginView ID="LoginView1" runat="server"&gt;
                                  &lt;RoleGroups&gt;
                                      &lt;asp:RoleGroup Roles="Administrator"&gt;
                                          &lt;ContentTemplate&gt;
                                              &lt;div class='rowTableDiv rowInfoAllNewsUC'&gt;
                                                  &lt;asp:Panel ID="pnlEdit" CssClass='colTableDiv' runat="server"&gt;
                                                      &lt;div class='colTableDiv colInfoAllNewsUC'&gt;
                                                          &lt;asp:LinkButton ID="lbEdit" 
                                                              CommandArgument='&lt;%# Bind("Id") %&gt;' 
                                                              PostBackUrl='&lt;%# String.Format("~/Page/Admin/InsertProduct.aspx?Mode=Edit&amp;Id={0}", Eval("Id"))%&gt;' 
                                                              Font-Underline="false" 
                                                              CommandName="edit" 
                                                              runat="server"&gt;
                                                              &lt;img id='img2' class='noBorder imgEditAllNewsUC' src="../../image/note_edit.png" alt="ویرایش" /&gt;
                                                          ویراش&lt;/asp:LinkButton&gt;
                                                           &lt;asp:LinkButton ID="lbDelete" CommandArgument='&lt;%# Bind("Id") %&gt;' Font-Underline="false" CommandName="delete" runat="server"&gt;
                                                              &lt;img id='img1' class='noBorder imgEditAllNewsUC' src="../../image/delete.png" alt="حذف" /&gt;
                                                          حذف&lt;/asp:LinkButton&gt;
                                                      &lt;/div&gt;
                                                  &lt;/asp:Panel&gt;
                                              &lt;/div&gt;
                                          &lt;/ContentTemplate&gt;
                                      &lt;/asp:RoleGroup&gt;
                                  &lt;/RoleGroups&gt;
                              &lt;/asp:LoginView&gt;
                              &lt;div class="divHidden"&gt;
                                  &lt;asp:Label ID="lblID" runat="server" Text='&lt;%# Eval("ID") %&gt;'&gt;&lt;/asp:Label&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
              &lt;/Columns&gt;
              &lt;EmptyDataRowStyle CssClass="lblError" /&gt;
              &lt;PagerStyle CssClass="pagerGridView" /&gt;
          &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>My code behind is like bellow:</p>
  
  <pre><code>protected void GridViewAllProducts_RowCommand(object sender, GridViewCommandEventArgs e)
  {
      if (e.CommandName == "delete")
      {
          int productId = Convert.ToInt32(e.CommandArgument);
  
          string image = new ProductC().GetProductBy_Id(productId).Image;
  
          Result r = new ProductC().DeleteBy_Id(productId);
          if (r.IsSuccess)
          {
              File.Delete(Server.MapPath(image));
          }
  
          GridViewAllProducts.DataSource = new ProductC().GetAllProducts();
          GridViewAllProducts.DataBind();
      }
  }
  </code></pre>
  
  <p>I get error "<em>Input string was not in a correct format.</em>" at the following line:</p>
  
  <pre><code>int productId = Convert.ToInt32(e.CommandArgument);
  </code></pre>
  
  <p>What is the problem. Please help me. Thank you.</p>