Updating MySQL database with values from dynamically generated textboxes in different divs <p>I'll try my best to explain my problem here, forgive me if I use the wrong terms occasionally, I'm still pretty much a beginner, and quite terrible at explaining.</p> <p>My goal is to use Jquery to dynamically add textboxes, and then use C# to update the values in those textboxes into a mysql database.</p> <p>The database consists of four columns, UserID(PK), Date(PK), Subject(PK) and Hours. The goal is to be able to fill in the amount of hours you've worked on a subject on certain day of the current week.</p> <p>So far, I'm able to add a new textbox whenever I press the button for the day I want to update the data for. The problem I'm running into is that I have no idea how to build the mysql query in such a way that it correctly associates the entered values with the day they're entered for.</p> <p>My code so far:</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head runat="server"&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; &lt;/script&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div id="dag1" runat="server"&gt; &lt;input class="btnAdd" type="button" value="Monday" onclick="AddTextBox($(this).parent().attr('id'));" /&gt; &lt;/div&gt; &lt;div id="dag2" runat="server"&gt; &lt;input class="btnAdd" type="button" value="Tuesday" onclick="AddTextBox($(this).parent().attr('id'));" /&gt; &lt;/div&gt; &lt;div id="dag3" runat="server"&gt; &lt;input class="btnAdd" type="button" value="Wednesday" onclick="AddTextBox($(this).parent().attr('id'));" /&gt; &lt;/div&gt; &lt;div id="dag4" runat="server"&gt; &lt;input class="btnAdd" type="button" value="Thursday" onclick="AddTextBox($(this).parent().attr('id'));" /&gt; &lt;/div&gt; &lt;div id="dag5" runat="server"&gt; &lt;input class="btnAdd" type="button" value="Friday" onclick="AddTextBox($(this).parent().attr('id'));" /&gt; &lt;/div&gt; &lt;br /&gt; &lt;br /&gt; &lt;div id="TextBoxContainer"&gt; &lt;script type="text/javascript"&gt; function AddTextBox(day) { var value = "" var div = document.createElement('DIV'); div.innerHTML = '&lt;input name = "Subject" type="text" value = "' + value + '" /&gt;&lt;input name = "Hours" type="text" value = "' + value + '" /&gt;'; document.getElementById(day).appendChild(div); } &lt;/script&gt; &lt;/div&gt; &lt;br /&gt; &lt;asp:Button ID="btnPost" runat="server" Text="Post" OnClick="Post" /&gt; &lt;asp:Label ID="labeltest" Text="" runat="server" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And my codebehind:</p> <pre><code> protected string Values; protected void Post(object sender, EventArgs e) { string[] textboxValues = Request.Form.GetValues("Subject"); string[] textboxValues2 = Request.Form.GetValues("Hours"); MySqlConnection conn; MySqlCommand comm; string myConnectionString = "server=localhost;uid=root;database=caroussel"; using (conn = new MySqlConnection()) { try { int veld = 0; foreach (string val in textboxValues) { string value2 = textboxValues2[veld]; veld++; using (comm = new MySqlCommand("update uren set Subject=@Subject, Hours=@Hours WHERE Date=??? AND UserID=1, conn)) ; comm.Parameters.Add("@Subject", MySqlDbType.VarChar, 45); comm.Parameters["@Subject"].Value = val; comm.Parameters.Add("@Hours", MySqlDbType.Int16); comm.Parameters["@Hours"].Value = value2; comm.Parameters.Add("@UserID", MySqlDbType.Int16); comm.Parameters["@UserID"].Value = 1; comm.Parameters.Add("@Date", MySqlDbType.VarChar, 45); comm.Parameters["@Date"].Value = ????; { conn.ConnectionString = myConnectionString; conn.Open(); comm.ExecuteNonQuery(); conn.Close(); } } } finally { conn.Close(); } } } </code></pre> <p>If there's anything missing, or clarification is required, or I simply forgot something, please do tell, I'm rather stuck at the moment, and I haven't been able to find something that would help me so far.</p>