title: Registration using MultiView not working
body: <p>I have a MultiView to add employees that has 3 views. Please let me know the right way. Here is the poor code that I made which is not working. It will give new errors every time I modify something.</p>
  
  <p>Sorry I'm unable to post code here. Here is the post on ASP.NET forum</p>
  
  <p><a href="http://forums.asp.net/t/1825476.aspx/1?Registration+using+MultiView+not+working+" rel="nofollow">http://forums.asp.net/t/1825476.aspx/1?Registration+using+MultiView+not+working+</a></p>
  
  <pre><code>namespace EmployeeMultiView.AdminPages
  {
      public partial class _Default : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!Page.IsPostBack)
                  MultiView1.ActiveViewIndex = 0;
          }
  
          private void InsertInfo()
          {
              String KKSTechConnectionString = @"Data Source=USER-PC\SQLEXPRESS;Initial Catalog=KKSTech;Integrated Security=True";
              SqlConnection conn = new SqlConnection(KKSTechConnectionString);
              //Session["sessFirstName"] = Request["textbox1"];
  
                 try
                  {
                  conn.Open();
                  String insertstring = @"Insert INTO Emp
                  (EmpID,FirstName,LastName,MiddleName,Mob1,Mob2,Phone,Email1,Email2,EmpDesc,Accno,IFSCCode,Branch,ApproxUnitPrice)
                  values (@EmpID,@FirstName,@LastName,@MiddleName,@Mob1,@Mob2,@Phone,@Email1,@Email2,@EmpDesc,@Accno,@IFSCCode,@Branch,@ApproxUnitPrice)";
  
  
  
                  if (MultiView1.ActiveViewIndex == 0)
                  {
                      SqlCommand cmd = new SqlCommand("insertstring", conn);
                      cmd.CommandText = insertstring;
                      cmd.CommandType = CommandType.Text;
  
                      cmd.Parameters.AddWithValue("@EmpID", TextBox1.Text);
                      cmd.Parameters.AddWithValue("@FirstName", TextBox2.Text);
                      cmd.Parameters.AddWithValue("@LastName", TextBox3.Text);
                      cmd.Parameters.AddWithValue("@MiddleName", TextBox4.Text);
                      cmd.Parameters.AddWithValue("@Mob1", TextBox5.Text);
                      cmd.Parameters.AddWithValue("@Mob2", TextBox6.Text);
                      cmd.Parameters.AddWithValue("@Phone", TextBox7.Text);
                      cmd.Parameters.AddWithValue("@Email1", TextBox8.Text);
                      cmd.Parameters.AddWithValue("@Email2", TextBox9.Text);
                      cmd.Parameters.AddWithValue("@EmpDesc", TextBox10.Text);
                    }
  
                  else if (MultiView1.ActiveViewIndex == 1)
                  {
                      SqlCommand cmd2 = new SqlCommand("insertstring", conn);
                      cmd2.CommandText = insertstring;
                      cmd2.CommandType = CommandType.Text;
  
                      cmd2.Parameters.AddWithValue("@Accno", TextBox11.Text);
                      cmd2.Parameters.AddWithValue("@IFSCCode", TextBox12.Text);
                      cmd2.Parameters.AddWithValue("@Branch", TextBox13.Text);
                      cmd2.Parameters.AddWithValue("@ApproxUnitPrice", TextBox16.Text);
                      cmd2.ExecuteNonQuery();
                  }
                  else if (MultiView1.ActiveViewIndex == 2)
                  {
                      if (FileUpload1.HasFile)
                      {
                          byte[] productImage = FileUpload1.FileBytes;
  
  
  
                          String insertstring2 = @"Insert INTO Cert (CertName, CertLogo)
                                                           values(@CertName, @CertLogo)";
  
                          SqlCommand cmd3 = new SqlCommand("insertstring2", conn);
                          cmd3.CommandText = insertstring2;
                          cmd3.CommandType = CommandType.Text;
  
                          cmd3.Parameters.AddWithValue("@CertName", TextBox18.Text);
                          cmd3.Parameters.Add("@CertLogo", SqlDbType.VarBinary).Value = productImage;
  
                          cmd3.ExecuteNonQuery();
                      }
                  }
             }
  
              catch (System.Data.SqlClient.SqlException ex)
              {
  
                  string msg = "Insert Error:";
                  msg += ex.Message;
                  throw new Exception(msg);
              }
  
              finally
              {
                  Session.Abandon();
                  conn.Close();
              }
  
          }
          protected void Button1_Click(object sender, EventArgs e)
          {
  
  
              InsertInfo();
              MultiView1.ActiveViewIndex += 1;
  
          }
  protected void Button2_Click(object sender, EventArgs e)
          {
              MultiView1.ActiveViewIndex -= 1;
          }
  
          protected void Button5_Click(object sender, EventArgs e)
          {
              Response.Write("Successful");
          }
  
  
  
       }
  }
  </code></pre>