title: Error "Input string was not in a correct format"
body: <p>i am developing a web application project using asp.net, c#, and SQL server. The uploading process is working perfectly however downloading process got this error "Input string was not in a correct format". the column class_id in the table is varchar and i use it as DataKeyNames in the gridview</p>
  
  <pre><code>&lt;asp:LinkButton ID="lnkDownload" runat="server" Text="Download" OnClick="DownloadFile"
                  CommandArgument='&lt;%# Eval("class_id") %&gt;'&gt;&lt;/asp:LinkButton&gt;
  </code></pre>
  
  <p>the following code is used to download file when the download button which is in gridview clicked </p>
  
  <pre><code> protected void DownloadFile(object sender, EventArgs e)
      {
          int class_id = int.Parse((sender as LinkButton).CommandArgument); // the error is here
          byte[] bytes;
          string fileName, contentType;
          string constr = ConfigurationManager.ConnectionStrings["connection"].ConnectionString;
          using (SqlConnection con = new SqlConnection(constr))
          {
              using (SqlCommand cmd = new SqlCommand())
              {
  
                  cmd.Connection = con;
                  con.Open();
                  using (SqlDataReader sdr = cmd.ExecuteReader())//Error is here
                  {
                      sdr.Read();
                      bytes = (byte[])sdr["filePath"];
                      contentType = sdr["fileType"].ToString();
                      fileName = sdr["fileName"].ToString();
                  }
                  con.Close();
              }
          }
          Response.Clear();
          Response.Buffer = true;
          Response.Charset = "";
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          Response.ContentType = contentType;
          Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
          Response.BinaryWrite(bytes);
          Response.Flush();
          Response.End();
      }
  </code></pre>
  
  <p>how can this error be solved.
  thanks in advance </p>