Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I dont see <code>SafetySuggestionsID</code> defined anywhere...u have defined it as <code>statusID</code></p> <p>also when you are adding parameters, you are referring <code>ID</code>...please make these corrections or update the code in your query.</p> <pre><code>string updateCommand = "UPDATE SafetySuggestionsStatus SET ID= @statusID"; // where?? using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); //using (SqlCommand cmd = new SqlCommand(cmdText, conn)) using (SqlCommand cmd = new SqlCommand(updateCommand, conn)) { cmd.Parameters.AddWithValue("@statusID", statusID); cmd.ExecuteNonQuery(); } } </code></pre> <p><strong>Update</strong>:</p> <pre><code>"UPDATE SafetySuggestionsStatus SET ID= @statusID where ID=@SafetySuggestionsID""; </code></pre> <p>you have defined 2 parameters, but you are adding just 1 in your parameter colleciton:</p> <pre><code>cmd.Parameters.AddWithValue("@ID", statusID); // id should be statusID // also add @SafetySuggestionsID </code></pre> <p><strong>Update 2:</strong> in your <code>lnkSuggestionStatus_Click</code> event handler, get the value of the first column (ID) and store it in a class variable say safetySuggestionsId.</p> <p>Then in your <code>btnSendStatus_Click</code> event handler, you can simply add:</p> <pre><code>using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); //using (SqlCommand cmd = new SqlCommand(cmdText, conn)) using (SqlCommand cmd = new SqlCommand(updateCommand, conn)) { cmd.Parameters.AddWithValue("@statusID ", statusID); cmd.Parameters.AddWithValue("@SafetySuggestionsID", safetySuggestionsId); cmd.ExecuteNonQuery(); } } </code></pre> <p><strong>Update 3:</strong> Hope the following works as this is untested...:</p> <ol> <li><p>add a hidden field in your modal popup panel --> </p> <p></p></li> <li><p>then in your <code>lnkSuggestionStatus_Click</code> event handler, add:</p> <p>hiddenRowIndex.Value = row.Cells[1].Text; // trim if necessary</p></li> <li><p>then when you save, in your <code>btnSendStatus_Click</code> event handler, you can simply add: </p> <pre><code> ... ... { cmd.Parameters.AddWithValue("@statusID ", statusID); cmd.Parameters.AddWithValue("@SafetySuggestionsID", Convert.ToInt32(hiddenRowIndex.Value)); cmd.ExecuteNonQuery(); } // reset hiddenRowIndex hiddenRowIndex.Value = "-1"; } </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload