title: Listview Itemediting was not working
body: <p>I don't know why i got this error but my code i think is correct.</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;asp:ListView ID="lvwData" runat="server" OnItemCommand="Student_OnItemCommand" EnableViewState="true"
      DataKeyNames="id"&gt;
      &lt;LayoutTemplate&gt;
          &lt;table class="table-list table-list-gridded" id="dataTable" border="0" cellspacing="0"
              cellpadding="5"&gt;
              &lt;thead&gt;
                  &lt;th class="id"&gt;
                      ROW #
                  &lt;/th&gt;
                  &lt;th&gt;
                      Student ID
                  &lt;/th&gt;
                  &lt;th&gt;
                      First Name
                  &lt;/th&gt;
                  &lt;th&gt;
                      Last Name
                  &lt;/th&gt;
                  &lt;th&gt;
                      Course
                  &lt;/th&gt;
                  &lt;th class="action"&gt;
                      &lt;span&gt;ACTIONS&lt;/span&gt;
                  &lt;/th&gt;
              &lt;/thead&gt;
              &lt;tbody id="itemPlaceholder" runat="server"&gt;
              &lt;/tbody&gt;
      &lt;/LayoutTemplate&gt;
      &lt;ItemTemplate&gt;
          &lt;tr&gt;
              &lt;td align="center" class="id"&gt;
                  &lt;%# Container.DataItemIndex + 1 %&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="lblStudentID" runat="server" Text='&lt;%# Eval("student_id") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="lblFirstName" runat="server" Text='&lt;%# Eval("firstname") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="lblLastName" runat="server" Text='&lt;%# Eval("lastname") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;asp:Label ID="lblCourse" runat="server" Text='&lt;%# Eval("course") %&gt;' /&gt;
              &lt;/td&gt;
              &lt;td align="center" class="action"&gt;
                  &lt;asp:LinkButton ID="lnkEdit" class="btn btn-small" Text="Edit" CommandName="Edit"
                      CommandArgument='&lt;%# Eval("ID") %&gt;' runat="server"&gt;&lt;i class="icon-pencil"&gt;&lt;/i&gt;&lt;/asp:LinkButton&gt;
                  &lt;asp:LinkButton ID="DeleteLinkButton" Text="Delete" CommandName="Delete" CommandArgument='&lt;%# Eval("ID") %&gt;'
                      OnClientClick="return confirm('Are you sure you want to delete this Employee?');"
                      runat="server" class="btn btn-small"&gt;&lt;i class="icon-remove"&gt;&lt;/i&gt;&lt;/asp:LinkButton&gt;
              &lt;/td&gt;
      &lt;/ItemTemplate&gt;
      &lt;EmptyDataTemplate&gt;
          &lt;div class="centered alert alert-error"&gt;
              No list of records to display.
          &lt;/div&gt;
      &lt;/EmptyDataTemplate&gt;
  &lt;/asp:ListView&gt;
  </code></pre>
  
  <p>C# codes behind:</p>
  
  <pre><code>protected void Student_OnItemCommand(object sender, ListViewCommandEventArgs e)
  {
      switch (e.CommandName)
      {
          case "Delete":
              ListViewDataItem dataItem = (ListViewDataItem)e.Item;
              string employeeID = lvwData.DataKeys[dataItem.DisplayIndex].Value.ToString();
  
              DBConnect db = new DBConnect();
              db.Delete("delete from students where id = '" + employeeID + "'");
              Response.Redirect("~/Users/Student.aspx");
              break;
          case "Edit":
              mvStudents.ActiveViewIndex = 1;
              break;
      }
      //if (String.Equals(e.CommandName, "Delete"))
      //{
  
      //}
      //else if (string.Equals(e.CommandName, "Edit"))
      //{
      //    ListViewDataItem dataItem = (ListViewDataItem)e.Item;
      //    string employeeID = lvwData.DataKeys[dataItem.DisplayIndex].Value.ToString();
  
  
      //}
  }
  </code></pre>
  
  <p>Stack Trace: </p>
  
  <blockquote>
    <p>[InvalidOperationException: The ListView 'lvwData' raised event
    ItemEditing which wasn't handled.]
    System.Web.UI.WebControls.ListView.OnItemEditing(ListViewEditEventArgs
    e) +305573 System.Web.UI.WebControls.ListView.HandleEdit(Int32
    itemIndex) +51
    System.Web.UI.WebControls.ListView.HandleEvent(EventArgs e, Boolean
    causesValidation, String validationGroup) +324
    System.Web.UI.WebControls.ListView.OnBubbleEvent(Object source,
    EventArgs e) +227 System.Web.UI.Control.RaiseBubbleEvent(Object
    source, EventArgs args) +37
    System.Web.UI.WebControls.ListViewDataItem.OnBubbleEvent(Object
    source, EventArgs e) +112
    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
    +37 System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +156
    System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
    eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
    sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
    +9528578 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    +1724</p>
  </blockquote>