title: Gridview delete row
body: <p>When i click on the delete button it does not call delete function. can anyone help me?</p>
  
  <pre><code>protected void GridViewQuestion_RowDataBound(object sender, GridViewRowEventArgs e)
          {
              if (e.Row.RowType == DataControlRowType.DataRow)
              {
                  ImageButton lb = (ImageButton)e.Row.FindControl("ImageButtonDelete");
  
                  lb.Attributes.Add("onclick", "javascript:return " +
                       "confirm('Are you sure you want to delete this record " +
                       DataBinder.Eval(e.Row.DataItem, "question") + "')");
              }
          }
  
          protected void GridViewQuestion_RowDeleting(object sender, GridViewDeleteEventArgs e)
          {
              int questionID = (int)GridViewQuestion.DataKeys[e.RowIndex].Value;
  
              TopicEntity.deleteQuestion(questionID);
  
              BindGridData();
          }
  
  public bool deleteQuestion(int QuestionID)
          {
              SqlConnection dbConnection = new SqlConnection(connectionString);
  
              SqlCommand dbCommand = new SqlCommand();
              dbCommand.CommandText = "DELETE FROM Question QuestionID=@QuestionID";
              dbCommand.Connection = dbConnection;
              dbCommand.Parameters.AddWithValue("@QuestionID", QuestionID);
  
              bool deleteSuccess = false;
  
              try
              {
                  dbConnection.Open();
                  dbCommand.ExecuteNonQuery();
                  deleteSuccess = true;
              }
              catch (Exception e)
              {
                  throw e;
              }
              finally
              {
                  dbConnection.Close();
              }
              return deleteSuccess;
          }
  </code></pre>