I have a simple WHDG with only 2 levels. I create a WHDS using two lists:
WebHierarchicalDataSource whds = new WebHierarchicalDataSource(); DataView dvTeams = new DataView(); dvTeams.ID = "Teams"; dvTeams.DataSource = TeamInformationBLL.GetTeamList(CurrentUser.UserLoginInfoId, true); DataView dvGames = new DataView(); dvGames.ID = "Games"; dvGames.DataSource = GameStatisticsBLL.GetCoachGames(CurrentUser.UserLoginInfoId, null); DataRelation drGames = new DataRelation("Teams", "TeamId", "Games", "TeamId"); whds.DataViews.Add(dvGames); whds.DataViews.Add(dvTeams); whds.DataRelations.Add(drGames); WebHierarchicalDataGrid1.DataSource = whds; WebHierarchicalDataGrid1.DataBind();
When the parent list (Teams) is empty (count=0) the page throws a null reference error on the .DataBind().
Why isn't it displaying the Empty Rows template?
Do you have the empty rows template defined? If so then this sounds like a bug. Thank you for letting us know.
You can also define error template so only the grid renders the error (or whatever you would like to render in case of an error).