title: How to get lists of 'id' field after insert in LINQ?
body: <p>I'm using this code to create dynamically row in Gridview and I'm using LINQ to insert those rows to DB. Now i want to return lists of ID after insert into DB but i don't know how.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#region [Get List Visitors]
  private void GetListVisitors() {
          int rowIndex = 0;
          StringCollection sc = new StringCollection();
              DataTable dtCurrentTable = (DataTable)ViewState["CurrentTable"];
              if (dtCurrentTable.Rows.Count &gt; 0)
              {
                  for (int i = 1; i &lt;= dtCurrentTable.Rows.Count; i++)
                  {
                      //extract the TextBox values
                      TextBox visitor_txtName = (TextBox)grdListVisitors.Rows[rowIndex].Cells[1].FindControl("txtName");
                      TextBox visitor_txtAdd = (TextBox)grdListVisitors.Rows[rowIndex].Cells[1].FindControl("txtAdd");
                      //ASPxComboBox visitor_cbxSex = (ASPxComboBox)grdListVisitors.Rows[rowIndex].Cells[1].FindControl("cbxSex");
  
                      sc.Add(visitor_txtName.Text + "," + visitor_txtAdd.Text);
                      rowIndex++;
                  }
                  //Store the current data to StringCollection
                  AddListVisitors(sc);
              }
  }
  #endregion
  
  #region [Add List Visitors]
  private void AddListVisitors(StringCollection sc)
  {
      try {
          List_Visitor add_visitors = new List_Visitor();
          string[] splitItems = null;
          foreach (string item in sc)
          {
              if (item.Contains(","))
              {
                  Travel_DBDataContext db = new Travel_DBDataContext();
                  splitItems = item.Split(",".ToCharArray());
                  add_visitors.Fullname = splitItems[0];
                  add_visitors.add = splitItems[1];
                  db.List_Visitors.InsertOnSubmit(add_visitors);
                  db.SubmitChanges();
              }
  
          }      
      }
      catch (Exception addvisitors_error) {
          Response.Write(addvisitors_error.Message + "_method addlistvisitor");
      }
  }
  #endregion
  </code></pre>