title: How to send each row ID from first table to all rows in second table in one click_button?
body: <p>I have two tables in SQL Server, both of tables have about 100+ rows. How to send each row ID from first table to all rows in second table in one click_button? Thanks.</p>
  
  <p><strong>UPD</strong> someting what dont work.
  I trying to send QString with value (of all needed rows) and after postback select row id of 1st table and upd 2nd table. The main problem, datasource after postback = null. </p>
  
  <pre><code>  public string idul;
          public int pro;
          public string nz;
          public string idul2;
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
                  foreach (DataRowView drv in dv)
                  {
                      idul = drv["IDUL"].ToString();
  
                  }
              }
  
          }
  
          protected void Button1_Click(object sender, EventArgs e)
          {
  
              string path = Server.MapPath(FileUpload1.FileName);
              FileUpload1.SaveAs(Server.MapPath(FileUpload1.FileName));
  
              Microsoft.Office.Interop.Excel.Application App = new Microsoft.Office.Interop.Excel.Application();
              Microsoft.Office.Interop.Excel.Workbook WB;
  
              WB = App.Workbooks.Open(path, ReadOnly: true);
  
              var sheet = (WB.Sheets[1] as Microsoft.Office.Interop.Excel.Worksheet);
              int lastrow = sheet.UsedRange.Columns["A"].Rows.Count();
              int count = sheet.UsedRange.Columns["A:A", Type.Missing].Rows["1:" + lastrow].Count();
  
  
              while (count &gt; 0)
              {
                  SqlConnection con_ul = new SqlConnection(WebConfigurationManager.ConnectionStrings["JJ"].ConnectionString);
                  string ins_ul = "INSERT INTO UL (NZ, Name) VALUES (@NZ, @Name)";
                  SqlCommand cmd_ul = new SqlCommand(ins_ul, con_ul);
  
                  cmd_ul.Parameters.AddWithValue("@NZ", pro);
                  cmd_ul.Parameters.AddWithValue("@Name", sheet.UsedRange.Cells[count, 1].Value.ToString());
  
                  cmd_ul.Connection.Open();
                  cmd_ul.ExecuteNonQuery();
                  cmd_ul.Connection.Close();
  
  
  
                  SqlConnection con_tsp = new SqlConnection(WebConfigurationManager.ConnectionStrings["JJ"].ConnectionString);
                  string ins_tsp = "INSERT INTO TSP (NZ, Name) VALUES (@NZ, @Name)";
                  SqlCommand cmd_tsp = new SqlCommand(ins_tsp, con_tsp);
  
                  cmd_tsp.Parameters.AddWithValue("@NZ", pro);
                  cmd_tsp.Parameters.AddWithValue("@Name", sheet.UsedRange.Cells[count, 1].Value.ToString());
  
                  cmd_tsp.Connection.Open();
                  cmd_tsp.ExecuteNonQuery();
                  cmd_tsp.Connection.Close();
  
                  count--;
                  pro++;
  
              }
  
              App.Quit();
              Label1.Text = "Загруженно " + pro + " записей!";
              System.Threading.Thread.Sleep(200);
              File.Delete(path);
              Button1.Enabled = false;
  
  
  
              Response.Redirect("WebForm1.aspx?pro="+pro);
  
          }
  
          protected void Button2_Click(object sender, EventArgs e)
          {
  
  
              idul = Request.QueryString["pro"];
              pro = Convert.ToInt32(idul);
  
              for (int i = pro; i &gt; -1; i--)
              {
                  wisp();
  
              }
  
  
          }
          public void wisp()
          {
  
  
  
              SqlConnection con_tsp = new SqlConnection(WebConfigurationManager.ConnectionStrings["JJ"].ConnectionString);
              string tsp1 = "UPDATE TSP SET IDUL=@IDUL WHERE NZ=@NZ";
              SqlCommand upd_tsp = new SqlCommand(tsp1, con_tsp);
  
              upd_tsp.Parameters.AddWithValue("@NZ", pro);
              upd_tsp.Parameters.AddWithValue("@IDUL", idul);
  
              upd_tsp.Connection.Open();
              upd_tsp.ExecuteNonQuery();
              upd_tsp.Connection.Close();
  
  
              pro--;
              Response.Redirect("WebForm1.aspx?pro=" + pro);
  
  
          }
  
      }
  }
  </code></pre>