I have DataGridView like this
s_code | s_name | t_result | ______________________________________ S2 | John | |
I used code below to display this
private void ViewStatus()
{
BindingSource bs1 = new BindingSource();
string val1 = label8.Text;
string val = label13.Text;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conString"].ToString());
SqlCommand cmd = new SqlCommand("SELECT s_code, s_name, t_result FROM " + val + " WHERE t_code='" + val1 + "'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
//con.Open();
//cmd.ExecuteNonQuery();
//da.Fill(dt);
dt.Locale = System.Globalization.CultureInfo.InvariantCulture;
da.Fill(dt);
bs1.DataSource = dt;
dataGridView1.DataSource = bs1;
dataGridView1.DataMember = label13.Text;
dataGridView1.EditMode = DataGridViewEditMode.EditProgrammatically;
And I want to edit value in "t_result" cell, and when i hit enter, i want it sends value to table in SQL Server and update it.
Any help would be much appreciated. Thank you.