How to call UpdateCommand from external button click?

2 posts, 0 answers
  1. Jason
    Jason avatar
    4 posts
    Member since:
    Jul 2015

    Posted 21 Sep 2015 Link to this post


    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;
              string answerid = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["AnswerID"].ToString();
              using (SqlConnection conn = new SqlConnection(connectionString))
                   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));
         catch (Exception)
              RadScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('There was a problem finding the ID, please contact support.')", true);
    Button click:

    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);
     How do I call the UpdateCommand event from the external button click?

  2. Konstantin Dikov
    Konstantin Dikov avatar
    1745 posts

    Posted 24 Sep 2015 Link to this post

    Hello Jason,

    Can you please refer to the answer in other forum post, where you have asked the same question:
    On a side note, for better tracking purposes and for all sides convenience, please try to avoid opening multiple threads with duplicated questions. Thank you for your understanding.

    Konstantin Dikov
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top