I briefly described the design approach in Part 1.  This part in the series will explore the ways in which the custom GridView communicates to the controller.  I extend my apologies for the lack of code.  I am limited in what I can provide.  I hope that these guidelines will help point you in the right direction.

Classes / Interfaces
  • CustomGridView - The GridView we are customizing
  • SelectionController - Responsible for the row selection behavior
  • IRowSelectionView - How CustomGridView and SelectionController communicate
To start off with, we need to know what settings the developer has chosen for this instance of the CustomGridView.  We have two basic options: SelectOnRowClick and SelectionMode (single or multiple).

Also, there are a lot of events we are interested in.  Primarily, we are interested in the RowCommand on GridView.  We will be using a command name of "MultiSelect" to handle all of the row clicks.

Other GridView events we will need:
  • RowCreated - to dress the row with an OnClick client-side event with the MultiSelect command.
  • Sorting, PageIndexChanged - results in clearing the selections
Some custom events:
  • DataSourceViewChanged - to tap into the OnDataSourceViewChanged protected GridView member, results in clearing the selections.
  • PageSizeChanging, RowEditing - results in clearing the selections
As you can see, there are a number of reasons to clear the selections.  I have paging enabled on all of my grids.  If a user changes the sorting, then the selected indices don't make sense anymore.  Also, if they change the page size or move from one page to another, these actions all invalidate the selections.

The view will likely evolve as we start to build the SelectionController.  We'll see what happens next time.

Next Time
Part 3 will dive into the SelectionController and how it will manage the selection behavior.  We'll see how it will use the IRowSelectionView in order to assert itself.
posted on Thursday, November 6, 2008 1:33 AM
Filed Under [ .Net Design ASP.Net C# Design Principles ]


No comments posted yet.

Post A Comment