I have 6 Labels and 6 Objects (1 Datepicker, 2 comboboxes and 3 textboxes). The Labels names are columnnames from a mysql database. And the content of the objects are the values for this.
If I click "Save" i want to save the values into the database.
What I found (but doesn't work because I have not the same amount of textboxes like the labels):
string query = "INSERT INTO "+ privateCustomerTablename +" (";
for (int i = 0; i < textboxes.Count; i++)
{
var column = labels[i];
if (i < textboxes.Count - 1)
query += column.Name + ",";
else
query += column.Name;
}
query += ") VALUES (";
for (int i = 0; i < textboxes.Count; i++)
{
var value = textboxes[i];
if (i < textboxes.Count - 1)
query += "'" + value.Text + "',";
else
query += "'" + value.Text + "')";
}
So I though to store all Children of a Stackpanel (I have 2 Stackpanels, 1 for Labels and 1 for the objects) to change textboxes.Count in the objectlist count.
But How I can store the Children of a Stackpanel with different objects in it in a list to do that?