Sunday, June 8, 2008

When 2 grids are linked

When you have:

  • a web page
  • 2 DataGridViews (parent/child relationship)
  • user wants to insert a new record into parent grid
  • parent grid has datasource set to Nothing so that EmptyDataTemplate shows
  • EmptyDataTemplate contains a DetailView
  • user fills in fields and clicks Insert
Then you get:
  • the parent record saves correctly; and
  • the page refreshes; but 
  • an error occurs because the child grid is linked to an empty Parent grid.
  • No amount of fiddling with the SelectedItem property of the Parent grid seems to work.


  • Hide the second grid until the user manually makes a selection on the Parent grid.

No comments:

Post a Comment