私は単純なグリッドビューを持っています。tableData を gridview にバインドするための SqlDataSource。
行の更新時に、セル ( int 型) の値を 1 増やしようとしています。これが私のコードですが、機能していません:
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = GridView1.Rows[e.RowIndex];
            string str = ((TextBox)(row.Cells[8].Controls[0])).Text;
            int conv = Convert.ToInt32(str);
            int set = conv + 1;
            string conn = "conn string";
            string sqlQuery = "UPDATE TableName SET Total =@Total";
            using (SqlConnection dataConnection = new SqlConnection(conn))
            {
                using (SqlCommand dataCommand = new SqlCommand(sqlQuery, dataConnection))
                {
                    dataCommand.Parameters.AddWithValue("Total", set);
                    dataConnection.Open();
                    dataCommand.ExecuteNonQuery();
                    dataConnection.Close();
                }
            }
        }
なぜ機能しないのかわかりません。現在の編集行のセルを 1 つ増やす必要があります。
ありがとう