查询执行得很好,但是问题在于,当该查询执行时,它不会更新百分比字段。可能是什么问题?

时间:2018-11-24 04:22:45

标签: c# asp.net sql-server

protected void GridView1_RowUpdating1(object sender, GridViewUpdateEventArgs e)
{
    int ID = (Convert.ToInt32(((Label)GridView1.Rows[e.RowIndex].FindControl("Label1")).Text));
    string FirstName = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox2")).Text;
    string LastName = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox3")).Text;
    string EmailID = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox4")).Text;
    string MobileNumber = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox5")).Text;
    string Class = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox6")).Text;
    string Stream = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox7")).Text;
    string query = "UPDATE REIGISTRATION SET FirstName='" + FirstName + "', LastName='" + LastName + "', EmailID='" + EmailID + "', MobileNumber='" + MobileNumber + "', Class='" + Class + "', Stream='" + Stream + "' WHERE ID='" + ID + "'";
    string cs = "Data Source=USER-PC\\LOCAL;Initial Catalog=STUDENT;Integrated Security=True";
    SqlConnection con = new SqlConnection(cs);
    SqlCommand cmd = new SqlCommand(query, con);
    con.Open();
    cmd.ExecuteNonQuery();
    con.Close();
    GridView1.EditIndex = -1;
    grid_binding();
}

0 个答案:

没有答案