Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
Error when removing row from a grid with groupby
posted

Hello,

I am using WebGrid version 8.2.20082.1000 with LoadOnDemand set to xml and viewtype set to OutlookGroupBy. The ASP.NET page has menu buttons where a user can select one or more rows from the grid and click the 'Delete' button. In the code behind I am using the following statement inside a for loops that iterates through the selected rows collection. 

uwgEmployees.DisplayLayout.Rows.Remove(row)

Everything works fine except when a user does a group by on the grid and then tries to delete selected rows. In this event the call to remove throws an exception. What is the correct method of removing selected rows from the grid?

 Thanks!

Parents
  • 45049
    posted

    When you're using Outlook group-by on WebGrid, the rows in the grid's Rows collection (or in DisplayLayout.Rows) are your group-by rows.  These rows can't be removed in this fashion.

    Theoretically, you'd need to find each row you want to delete under the Rows collection of the appropriate group-by row.  This isn't difficult, but also isn't trivial.

    However, there might be a better way to accomplish what you're after in client-side code.  Assuming that "grid" is a reference to a WebGrid on your page, the following JavaScript will delete all selected rows from the grid:

    grid.deleteSelectedRows();

Reply Children
No Data