I have 3 rows and 4 columns with textboxes in it i have to store all the textboxes data at a single click using asp.net and C sharp
Storing multiple rows data in save button using asp.net and c sharp
Hello,
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 27, 2012, 9:49 AM EDT
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Login_and_signup
{
public partial class Registration : System.Web.UI.Page
{
protected void btnSubmit_Click(object sender, EventArgs e)
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlConnection = new SqlConnection(connStr);
sqlConnection.Open();
string sqlQuery = "INSERT INTO Users(FirstName,LastName,UserName,Password,Address) VALUES(@FirstName,@LastName,@UserName,@Password,@Address)";
SqlCommand sqlCommand = new SqlCommand(sqlQuery, sqlConnection);
sqlCommand.CommandType = CommandType.Text;
sqlCommand.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = txtFirstName.Text.Trim();
sqlCommand.Parameters.Add("@LastName", SqlDbType.VarChar).Value = txtLastName.Text.Trim();
sqlCommand.Parameters.Add("@UserName", SqlDbType.VarChar).Value = txtUserName.Text.Trim();
sqlCommand.Parameters.Add("@Password", SqlDbType.VarChar).Value = txtPassword.Text.Trim();
sqlCommand.Parameters.Add("@Address", SqlDbType.VarChar).Value = txtAddress.Text.Trim();
int irows = sqlCommand.ExecuteNonQuery();
lblMessage.Text = "User inserted successfully...";
}
}
}
Thanks