You must Sign In to post a response.
  • Category: Windows 8

    How to add multiple textboxes and inserting to a DB

    Hello everyone,

    I am trying to add a button so if a user clicks that button, it will add a new text box and a drop down list.

    After that, there will be another box to save those textboxes and dropdownlists to a database.

    How do I do that? I searched the Internet but with no luck
    Also, I want those all text boxes to be inserted in one field in a database table.

    Thank you,
  • #761025

    You can try this code

    Client Side

    <asp:Button ID="BtSubmit" runat="server" Text="Submit" OnClick="BtSubmit_Click" />

    <asp:Button ID="BtFindControl" runat="server" Text="Save To DB" OnClick="BtFindControl_Click" />

    Server Side

    TextBox txt = new TextBox();
    DropDownList ddl = new DropDownList();
    protected void BtSubmit_Click(object sender, EventArgs e)
    txt.ID = "TxtName";

    ddl.ID = "ddlName";
    ddl.Items.Add("South Africa");

    protected void BtFindControl_Click(object sender, EventArgs e)
    SqlConnection con = new SqlConnection(strCon);
    SqlCommand sqlcm = new SqlCommand("Insert into TestRecord values('" + txt.Text + " " + ddl.SelectedItem.Text + "')", con);

    Name : Dotnet Developer-2015
    Email Id

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #761027
    Hello Moe,

    We have already provided you the solution on the link :

    Then why did you post the same question again. You should understand that code and try to work on that code. We are here to help you to solve your problem. You should also try for working and improving the code we have provided to you.

    Hope you understand.

    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #761106
    You should have responded to my last comment on that thread nirav instead of wasting your time talking non-sense here.

  • #761107
    Hello Moe,

    I have created the project for you and provided you the source code also. You should work on that code also to get exact output.

    For your kind info we are also a contributor here same as you.

    So please mind your language while responding to the thread.

    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #761112
    Closing as it is a duplicate to:
    Thanks & regards,
    Gaurav Kumar Arora
    Site Coordinator - DNS
    My blog -

This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.