Can you please help me to integrate Dynamic TextBox in ASP.NET and store data to SQL Server using button click. Every time user click on the button will generate 2 individual Textbox and another will store value to database.
to store the value to database , you can refer example below.
string cs=System.Configuration.ConfigurationManager.ConnectionStrings["myconectionstring"].ConnectionString;
SqlConnection con = new SqlConnection(cs);
SqlCommand cmd = new SqlCommand("INSERTINTO TEST (name,fathername) VALUES('" + TextBox1.Text + "','" + TextBox1.Text + "')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
Regards
Deepak
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Thanks for the response. This will create Singel TextBox whereas I am looking for 2 Horizontal TextBox and store it to SQL Database with per button click. Can you help me in this case please?
So far I am able to generate two horizontal TextBox but unable to store those data in Database.
so I hope now you are clear that how to use that code to insert data in database.
further , you just need to modify the code as per your requirement.
Regards
Deepak
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Thanks for the response. This will create Singel TextBox whereas I am looking for 2 Horizontal TextBox and store it to SQL Database with per button click. Can you help me in this case please?
So far I am able to generate two horizontal TextBox but unable to store those data in Database.
Hi kowserhossain,
do you keep the code for generate two horizontal textbox and store it into database? Can you share it to me through email? lysanchen928@gmail.com
None
0 Points
2 Posts
Multiple Dynamic TextBox in ASP.NET
Nov 09, 2017 05:22 AM|kowserhossain|LINK
Can you please help me to integrate Dynamic TextBox in ASP.NET and store data to SQL Server using button click. Every time user click on the button will generate 2 individual Textbox and another will store value to database.
Example:
[ TextBox1 ] [TextBox2]
|New Row| |Save|
Contributor
2990 Points
1210 Posts
Re: Multiple Dynamic TextBox in ASP.NET
Nov 09, 2017 07:10 AM|Deepak Panchal|LINK
Hi kowserhossai,
to generate the textbox dynamically you can refer the example below.
below is the code to fetch the values from textbox which you can stored in database.
for a detailed example refer link below.
Get Value (Text) of dynamically created TextBox in ASP.Net using C# and VB.Net
to store the value to database , you can refer example below.
Regards
Deepak
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
None
0 Points
2 Posts
Re: Multiple Dynamic TextBox in ASP.NET
Nov 09, 2017 09:40 AM|kowserhossain|LINK
Hi Deepak,
Thanks for the response. This will create Singel TextBox whereas I am looking for 2 Horizontal TextBox and store it to SQL Database with per button click. Can you help me in this case please?
So far I am able to generate two horizontal TextBox but unable to store those data in Database.
Contributor
2990 Points
1210 Posts
Re: Multiple Dynamic TextBox in ASP.NET
Nov 10, 2017 01:42 AM|Deepak Panchal|LINK
Hi kowserhossai...,
you had mentioned that,"So far I am able to generate two horizontal TextBox but unable to store those data in Database."
so here, I will not show you how to create two textboxes dynamically, because you already done it.
I will show you how to insert value in database.
first of all you need to create table with two fields. here I am creating just one field. you can modify the table design as per your requirement.
then try to connect the database using "Server Explorer".
then come to the code behind and add namespace below.
then go to the "GetTextBoxValues" Function.
modify the code like below.
Output:
so I hope now you are clear that how to use that code to insert data in database.
further , you just need to modify the code as per your requirement.
Regards
Deepak
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
None
0 Points
1 Post
Re: Multiple Dynamic TextBox in ASP.NET
Nov 08, 2018 02:25 PM|lysan|LINK
Hi kowserhossain,
do you keep the code for generate two horizontal textbox and store it into database? Can you share it to me through email? lysanchen928@gmail.com