How to Update in the GridView if the headers are not databound
<p><img src="http://i.stack.imgur.com/Y4qHm.jpg" alt="enter image description here">
I have a <code>GridView</code>, and the header field of the <code>GridView</code> are the items from a <code>ListBox</code> in my program. Therefore the number of columns generated is dynamic every time I run. So when I click on <strong>Update</strong> in the <code>Gridview</code>, the data entered in <code>TextBox</code> of that row has to be updated irrespective of the header field. Also the <code>TextBox</code> should be validated to accept only integer.</p>

<p>The .cs code for <code>GridView</code> display is:</p>

<pre><code>protected void DONE4_Click(object sender, EventArgs e)
    {

        DataTable dt = new DataTable();
        DataRow rw = default(DataRow);
        for (int i = 0; i &lt; ListBox1.Items.Count; i++)
        {
            dt.Columns.Add(ListBox1.Items[i].ToString(),System.Type.GetType("System.String"));
        }

        for (int j = 0; j &lt; count; j++)
        {
            rw = dt.NewRow();
            for (int i = 0; i &lt; ListBox1.Items.Count; i++)
            {
                rw[ListBox1.Items[i].ToString()] = " ";
            }
            dt.Rows.Add(rw);
        }
        GridView2.DataSource = dt;
        GridView2.DataBind();
        }
    }
</code></pre>

<p>Can anyone help me on this issue with a code for Updating? Thank you..
Hope the question is clear.</p>
