I have a web form that populates data from the database. The user can also edit the populated data and save it again. Why doesn't the new data populate the textboxes. Instead the old data is still showing?
Here is my populated code:
if (!IsPostBack)
{
if (TextBoxINST_ID.Text.Trim().Length > 0)
{
SqlConnection con44 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con44.Open();
SqlCommand scmd44 = new SqlCommand("Select FT_UNDERGR, FT_GRAD, FTE_UNDERG, FTE_GRAD, NON_CREDIT, TOTAL_FTE, FCFTUHC, FCFTPBHC, FCPTUHC, FCPTPBHC, NCHC, UnderG12, Postb9, Total123b4b, THCAS, FTE40, HC50, FTE4050 from Table55 where User_ID = '" + TextBoxUser_ID.Text + "'", con44);
SqlDataReader dr44 = scmd44.ExecuteReader();
if (dr44.Read())
{
TextBox1.Text = dr44["FT_UNDERGR"].ToString();
TextBox2.Text = dr44["FT_GRAD"].ToString();
TextBox3.Text = dr44["FTE_UNDERG"].ToString();
TextBox4.Text = dr44["FTE_GRAD"].ToString();
TextBox4.Text = dr44["NON_CREDIT"].ToString();
TextBox5.Text = dr44["TOTAL_FTE"].ToString();
TextBox6.Text = dr44["FCFTUHC"].ToString();
}
con44.Close();
dr44.Close();
}
}
}
Here is my Save Button code:
protected void ButtonSave_Click(object sender, EventArgs e)
{
SqlConnection con7 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
con7.Open();
SqlCommand cmd = new SqlCommand("Insert into Table56 (User_ID, FT_UNDERGR, DATE, FT_GRAD, FTE_UNDERG, FTE_GRAD, NON_CREDIT, TOTAL_FTE, FCFTUHC, FCFTPBHC, FCPTUHC, FCPTPBHC, NCHC, UnderG12, Postb9, Total123b4b, FTEYR, THCAS, FTE40, HC50, FTE4050) values (@INST_ID, @FT_UNDERGR, @DATE, @FT_GRAD, @FTE_UNDERG, @FTE_GRAD, @NON_CREDIT, @TOTAL_FTE, @FCFTUHC, @FCFTPBHC, @FCPTUHC, @FCPTPBHC, @NCHC, @UnderG12, @Postb9, @Total123b4b, @FTEYR, @THCAS, @FTE40, @HC50, @FTE4050);", con7);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@User_ID", TextBoxUser_ID.Text);
cmd.Parameters.AddWithValue("@FT_UNDERGR", TextBox1.Text);
cmd.Parameters.AddWithValue("@FT_GRAD", TextBox2.Text);
cmd.Parameters.AddWithValue("@FTE_UNDERG", TextBox3.Text);
cmd.Parameters.AddWithValue("@FTE_GRAD", TextBoxTHGDR.Text);
cmd.Parameters.AddWithValue("@NON_CREDIT", TextBox4.Text);
cmd.Parameters.AddWithValue("@TOTAL_FTE", TextBox5.Text);
cmd.Parameters.AddWithValue("@FCFTUHC", TextBox6.Text);
cmd.Parameters.AddWithValue("@FCFTPBHC", TextBoxTNFG.Text);