I have an external button that needs to call my UpdateCommand event, but I am not sure how to do it. Here is what I have so far:
protected void RadGrid2_UpdateCommand(object sender, GridCommandEventArgs e){ String connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["KBConnectionString"].ConnectionString; try { string answerid = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["AnswerID"].ToString(); using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); SqlCommand cmd = new SqlCommand("UPDATE Answers SET Answer_Name = @prmAnswer_Name, Answer = @prmAnswer, TimeAdded = CURRENT_TIMESTAMP WHERE AnswerID = " + answerid, conn); cmd.Parameters.Add(new SqlParameter("@prmAnswer_Name", RadTextBox1.Text)); cmd.Parameters.Add(new SqlParameter("@prmAnswer", RadEditor.Text)); cmd.ExecuteNonQuery(); conn.Close(); } } catch (Exception) { RadScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('There was a problem finding the ID, please contact support.')", true); } }
protected void RadButton2_Click(object sender, EventArgs e){ //CommandEventArgs cea = new CommandEventArgs(RadTextBox1.Text, RadEditor.Text); //GridCommandEventArgs args = new GridCommandEventArgs(null, "Edit", cea); //RadGrid2_UpdateCommand(sender, args);}