How do I display Country and City information like below?

  • India
    • Delhi
    • Bangalore
    • Chennai
  • USA
    • New York
    • Chicago
  • UK
    • London

For this example, we will use GridView and ObjectDataSource.

The CityHelper class fetches data from database. Fill a collection of countries. And within each country, fill a collection of cities.

Display countries in a GridView. Within a template column, define an inner GridView to display cities. The outer GridView is bound to the ObjectDataSource.

Handle the OnRowDataBound of the outer GridView. Find the inner GridView. Bind it to the cities collection.


Nested GridViews Bound to ObjectDataSource
Tagged on: