I'm trying to use the selected value from a dropdown as a parameter in a update query to update the name for that selected item, but the update query doesn't work. The dropdown is bounded and extracts data from a sql table,the new name is captured from a textfield. Here is my code:
protected void UpdateName_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(cs))
{
SqlDataAdapter da = new SqlDataAdapter("update z_SignAssets set signAsset =@asset where signAssetID =@id",con);
int dropdownValue = Convert.ToInt32(SignAssetDropDown.SelectedValue);
da.SelectCommand.Parameters.AddWithValue("@asset", newNameTextField.Text);
da.SelectCommand.Parameters.AddWithValue("@id", dropdownValue);
UpdateName.Visible = false;
newNameTextField.Visible = false;
checkcost.Visible = true;
EditName.Visible = true;
}
}