Whenever update the values in the text box.. its not submitted and update in database.
Thanks and regards
Here is my code :
namespace sys.System
{
public partial class spareedit : System.Web.UI.Page
{
SqlConnection dbCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["sqlServer2"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) {
dbCon.Open();
SqlCommand cmd = new SqlCommand("SELECT [Category],[Part Number],[Description],[Contract],[Current Quantity],[Site] FROM [demo].[dbo].[Sparepartslist] where [Part Number] = '" + Request.QueryString["id"] + "' and [site] = '" + Session["site"] + "'", dbCon);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read()) {
lblDescription.Text = dr["Description"].ToString();
lblpartnumber.Text = dr["Part Number"].ToString();
lblContract.Text = dr["Contract"].ToString();
txtQuantity.Text = dr["Current Quantity"].ToString();
}
dr.Close();
dbCon.Close();
}
}
protected void txtQuantity_TextChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string str = txtQuantity.Text;
SqlCommand com;
dbCon.Open();
com = new SqlCommand("Update into Sparepartslist values(@Current Quantity)", dbCon);
com.Parameters.AddWithValue("@Current Quantity", txtQuantity.Text);
com.ExecuteNonQuery();
com.Dispose();
dbCon.Close();
Response.Write("Records successfully updated");
clear();
}
void clear()
{
txtQuantity.Text = "";
}
}
}