title: Adding multiple rows to a datatable for dynamically created columns
body: <p>Hi all I am getting a string as follows for the data to be inserted as follows in a variable.</p>
  
  <p>I have written a code to frame it as <code>DataTable</code> as follows:</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
          {
              var vData = "ID=1;Name='XYZ';ID=2;Name='PQR'";
              var values = vData.Replace(";", ",");
              var cols = values.Split(',');
              DataTable dt = new DataTable();
              for (int i = 0; i &lt; cols.Length; i++)
              {
                  var p = cols[i].Split('=');
                  if (!dt.Columns.Contains(p[0].ToString()))
                      dt.Columns.Add(p[0].ToString());
              }
              DataRow dr = dt.NewRow();
              for (int j = 0; j &lt; dt.Columns.Count; j++)
              {
                  var value = cols[j].Split('=');
                  dr[j] = value[1];
              }
              dt.Rows.Add(dt);
          }
  </code></pre>
  
  <p>But this is adding only one row as the column will always be <code>2</code>, but I need add multiple rows if the data exceeds</p>