title: How to display same format repeater for each row that has the same cell value
body: <p>I have 50 different format repeaters. Each has to be bind according to the state.</p>
  
  <p>I created a gridview with checkboxes. Whichever rows are checked to display those rows data in the corresponding repeater. </p>
  
  <p>I am sending to the stored procedure multiple parameter and return a datatable. I loop through the datatable and on button click I get all repeaters except when the state is the same - it returns only the last one. I debug and the code runs through it but overwrites the previous row that had that state. How can I display all repeaters for the same state?</p>
  
  <pre><code>protected void GetVinData()
  {
      SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["DBConnection"]);
      SqlCommand cmmd = new SqlCommand();
      cmmd.CommandType = CommandType.StoredProcedure;
      cmmd.CommandText = c
      cmmd.Connection = cn;
      cn.Open();
  
      try
      {
          cmmd.Parameters.Add("@POLICY", SqlDbType.VarChar);
          cmmd.Parameters["@POLICY"].Value = ddlPolicy.SelectedValue;
          cmmd.Parameters.Add("@VIN", SqlDbType.VarChar);
          cmmd.Parameters["@VIN"].Value = txtMsg.Value;
  
          DataTable dt = new DataTable();
          SqlDataAdapter adapter = new SqlDataAdapter(cmmd);
          adapter.Fill(dt);
  
          foreach (DataRow dr in dt.Rows)
          {
                  SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["DBConnection"]);
                  SqlCommand cmd = new SqlCommand();
                  cmd.CommandType = CommandType.StoredProcedure;
                  cmd.CommandText = "GetAllVinNumbers";
                  cmd.Connection = conn;
  
                  cmd.Parameters.Add("@POLICY", SqlDbType.VarChar);
                  cmd.Parameters["@POLICY"].Value = ddlPolicy.SelectedValue;
                  cmd.Parameters.Add("@VIN", SqlDbType.VarChar);
                  cmd.Parameters["@VIN"].Value = dr["VIN"].ToString();
  
                  if (dr["STATE"].ToString() == "AL")
                  {
                      try
                      {
  
                          if (conn.State != ConnectionState.Open)
                          {
                              conn.Open();
                          }
                          Repeater_AL.DataSource = cmd.ExecuteReader();
                          Repeater_AL.DataBind();
                          Repeater_AL.Visible = true;
                          conn.Close();
                          conn.Dispose();
                      }
                      catch (Exception ex)
                      {
                          lblMessage.Text = ex.Message;
                          lblMessage.Visible = true;
                      }
  
                      finally
                      {
                          conn.Close();
                          conn.Dispose();
                      }
                  }
                  else if (dr["STATE"].ToString() == "AK")
                  {
  
                      try
                      {
                          if (conn.State != ConnectionState.Open)
                              conn.Open();
                          Repeater_AK.DataSource = cmd.ExecuteReader();
                          Repeater_AK.DataBind();
                          Repeater_AK.Visible = true;
                          conn.Close();
                          conn.Dispose(); 
                      }
                      catch (Exception ex)
                      {
                          lblMessage.Text = ex.Message;
                          lblMessage.Visible = true;
                      }
  
                      finally
                      {
                          conn.Close();
                          conn.Dispose();
                      }
  
                  }
                  else if (dr["STATE"].ToString() == "AZ")
                  {
  
                      try
                      {
                          if (conn.State != ConnectionState.Open)
                              conn.Open();
                          Repeater_AZ.DataSource = cmd.ExecuteReader();
                          Repeater_AZ.DataBind();
                          Repeater_AZ.Visible = true;
                          conn.Close();
                          conn.Dispose();
  
                      }
                      catch (Exception ex)
                      {
                          lblMessage.Text = ex.Message;
                          lblMessage.Visible = true;
                      }
  
                      finally
                      {
                          conn.Close();
                          conn.Dispose();
                          if (Repeater_AZ.Visible == true)
                          {
                              Repeater_AZ.Visible = true;
                          }
                      }
  
  
                  } ... and so on for 50 states
  </code></pre>