Question: There's a dropdown displaying 1-10 from where the user selects the number of textboxes he wants - if he chooses unlimited, it shows him a textbox wherein he enters the exact number of textboxes he'd like. if he enters 40, it shows him 40 textboxes which are created at runtime.

My question is, how do I enter the data from 40 - or 'whatever number he enters' textboxes into the MS SQL database. There's no way I can create a column name dynamically, and that'd be too tedious and messy. Is there any way I can do this?

Answer: 
When you create the textboxes, you can give them sequential ID's, and then iterate through these on the postback, writing the values to your database.

For example:

```
/// <Summary>
///  This would be fired when the user enters the number of textboxes
///  the want and click the 'Create Textboxes' button.
/// </Summary>
protected void CreateTextBoxes_Click(object sender, EventArgs e)
{
    // Check how many textboxes the user wants
    int count = Convert.ToInt32(CountTextBox.Text);

    // Generate the number of textboxes requested
    // and add them to the page
    for (int i=0; i < count; i++)
    {
        // Create the textbox
        TextBox textbox = new Textbox();

        // Set the ID so we can access it later
        textbox.ID = "TextBox_" + i;

        // Add the textbox to the panel
        TextBoxPanel.Controls.Add(textbox);
    }
}

/// <Summary>
///  This would be fired when the user has entered values in the textboxes
///  and clicked the Save button to save the values to the database.
/// </Summary>
protected void SaveButton_Click(object sender, EventArgs e)
{
    // Check how many textboxes the user created
    int count = Convert.ToInt32(CountTextBox.Text);

    // Loop through them
    for (int i=0; i < count; i++)
    {
         // Get the TextBox
         TextBox textbox = (TextBox) FindControl("TextBox_" + i);

         // Get the value
         string val = textbox.Text;

         // Insert into DB
         SaveValueToDatabase(val);
    }
]

```
Have you considered storing the data as an XML field in the database?

If you have 40+ text boxes you could just have a simple schema to store them like:

```
<YourData>
    <TextBox ID="TextBox1">Value1</TextBox>
    <TextBox ID="TextBox2">Value2</TextBox>
    <TextBox ID="TextBox3">Value3</TextBox>
    ... etc ...
</YourData>

```

No need for dynamic fields in your DB. You should also store the schema somewhere as well. This is a good way to store dynamic data that can change from record to record.