title: Why DetailsView.ChangeMode method does not fire ModeChanging and ModeChanged events?
body: <p>I have an ASP.NET WebApplication page with DetailsView bounded to SqlDataSource.</p>
  
  <p>When I try to change mode by auto-generated Edit or Insert buttons, events are fired.</p>
  
  <p>When I try to change mode programmatically by DetailsView.ChangeMode method call (inside  custom button click), ModeChanging and ModeChanged events are not fired.</p>
  
  <p>Why it does not work ?</p>
  
  <p>There is aspx listing:</p>
  
  <pre><code>&lt;form id="form1" runat="server"&gt;
  &lt;div&gt;
      &lt;h1&gt;&lt;asp:Label ID="Label" runat="server" Text="ReadOnly" /&gt;&lt;/h1&gt;
      &lt;asp:DetailsView ID="DetailsView" runat="server" 
          DataSourceID="SqlDataSource" 
          EnableModelValidation="True"
          AllowPaging="True" 
          AutoGenerateEditButton="True"
          AutoGenerateInsertButton="True" 
          OnModeChanged="DetailsView_ModeChanged"&gt;
          &lt;FooterTemplate&gt;
          &lt;/FooterTemplate&gt;
      &lt;/asp:DetailsView&gt;
      &lt;asp:SqlDataSource ID="SqlDataSource" runat="server" 
          ConnectionString="&lt;%$ ConnectionStrings:PEMDConnectionString %&gt;"
          SelectCommand="SELECT * FROM [evd].[WaterTemplates]"
          InsertCommand="INSERT INTO [evd].[WaterTemplates] (TemplateName,TemplateDescription) VALUES (@Name,@Description)" /&gt;
      &lt;asp:Button ID="InsertByChangeModeButton" runat="server" 
          OnClick="InsertByChangeModeButton_Click" 
          Text="Insert By ChangeMode" /&gt;
      &lt;asp:Button ID="EditByChangeModeButton" runat="server" 
          OnClick="EditByChangeModeButton_Click" 
          Text="Edit By ChangeMode" /&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and here is code behind:</p>
  
  <pre><code>namespace WebApplication1
  {
      public partial class _Default : System.Web.UI.Page
      {
          protected override void OnPreRender(EventArgs e)
          {
              base.OnPreRender(e);
              switch (DetailsView.CurrentMode)
              {
                  case DetailsViewMode.Edit:
                  case DetailsViewMode.Insert:
                      EditByChangeModeButton.Visible = false;
                      InsertByChangeModeButton.Visible = false;
                      break;
                  case DetailsViewMode.ReadOnly:
                      InsertByChangeModeButton.Visible = true;
                      EditByChangeModeButton.Visible = true;
                      break;
                  default:
                      break;
              }
          }
  
          protected void InsertByChangeModeButton_Click(object sender, EventArgs e)
          {
              DetailsView.ChangeMode(DetailsViewMode.Insert);
          }
  
          protected void EditByChangeModeButton_Click(object sender, EventArgs e)
          {
              DetailsView.ChangeMode(DetailsViewMode.Edit);
          }
  
          protected void DetailsView_ModeChanged(object sender, EventArgs e)
          {
              switch (DetailsView.CurrentMode)
              {
                  case DetailsViewMode.Edit:
                      Label.Text = "Edit";
                      break;
                  case DetailsViewMode.Insert:
                      Label.Text = "Insert";
                      break;
                  case DetailsViewMode.ReadOnly:
                      Label.Text = "ReadOnly";
                      break;
                  default:
                      break;
              }
          }
      }
  }
  </code></pre>