title: "Input string was not in a correct format."
body: <p>I am working on a project in which I have a form through which I can edit a question available in a list view. Whenever I select a row from the list view and click on the 'modify' button, the text boxes above the list view load the question and its options.
  This means that when I select a row in the list view and click on the 'modify' button, the question loads itself into the text boxes. I edit the question there and click on 'save' to save changes, but I am not able to access the data in the text boxes. It says <code>{"Input string was not in a correct format."}</code>.</p>
  
  <p>My code of the form <code>frmFormWizard</code>'s 'edit' button is given below:</p>
  
  <p><strong>frmFormWizard.cs Code:</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Windows.Forms;
  using System.Data.Sql;
  using System.Data.SqlClient;
  
  namespace SurveyBuilder
  {
      public partial class frmFormWizard : Form
      {
          int intPanelNumber = 1;
          Boolean blnCancel = false;
          //int intFlag = 1;
  
          public frmFormWizard()
          {
              InitializeComponent();
          }
  
          ...
  
          private void btnEditTwoOrMoreOptions_Click(object sender, EventArgs e)
          {
              int QuestionID;           
              string sql;
  
              QuestionID = Convert.ToInt32(lvTwoOrMoreOptions.SelectedItems[0].Text.ToString());
              {
                  SqlConnection cn = new SqlConnection();
                  SqlCommand rs = new SqlCommand();
                  SqlDataReader sdr = null;
                  clsConnection clsCon = new clsConnection();
  
                  clsCon.fnc_ConnectToDB(ref cn);
  
                  sql = "";
                  sql += "SELECT * FROM SurveyQuestionLog WHERE SurveyQuestionLog.QuestionLogID = "+ QuestionID +"";
                  //sql += "SELECT * FROM SurveyQuestionLog";
  
                  rs.Connection = cn;
                  rs.CommandText = sql;
                  sdr = rs.ExecuteReader();
  
                  while (sdr.Read())
                  {
                      txtTwoOrMoreQuestions.Text = (string)sdr["Question"];
                      txtOption1.Text = (string)sdr["Choice1"];
                      ...
                  }
  
                  sdr.Close();
                  rs = null;
                  cn.Close();
              }
          }
  </code></pre>
  
  <p>Whenever I try to compile the code it says <code>"{"Input string was not in a correct format."}"</code> and this error is shown on the following line:</p>
  
  <pre><code> QuestionID = Convert.ToInt32(lvTwoOrMoreOptions.SelectedItems[0].Text.ToString());
  </code></pre>
  
  <p>Please let me know what I am doing wrong.</p>