Hi,
I've been having a really hard time with the WHDG performance. I have a parent and child band which are being fed by two sqldatasources into one WebHierarchicalDataSource. The query in the child's datasource is simply "select * from [jobparts]." Every time I hit the expand button, that sqldatasource runs a "select * from [jobparts]" which returns thousands of records and then picks out the one or two rows it needs to display in the child band. (You can see that by watching the sqldatasource_selected event and checking the affectedrows property of e)
So I tried using manual load on demand to load the data in code in the rowisland_populating event when the expand button was hit. Same problem, since the sqldatasource of the child is still connected to my webhierarchicaldatasource, it does the whole select process and THEN it populates the WHDG through my code. So then I changed the query in the child's sqldatasource to something that doesn't return any records but that makes me lose the expand button on the parent band all together so I can never get into the rowisland_populating event at all.
Is there a way to set this up so that the child datasources only select what they need from the database? I was thinking of setting up some crazy custom paging scheme for the chld band queries, but I don't have enough Tylenol in the office to start thinking about that.
Edit: I just figured out a possible way by using the WebHierarchicalDataGrid1_RowIslandDataBinding event and changing the selectcommand of the sqldatasource of the child there. I have to make sure not to change it when the parent grid loads so that the expand buttons will be created. I'm not sure how to get the parent rows datakey in that event though.
Thanks, Ed
Thanks for the reply. I will get to testing this in depth over the weekend.
Ed
Hello Ed,
Sorry for a delay.
The property can be set as following:
protected void WebHierarchicalDataGrid1_InitializeRow(object sender, RowEventArgs e)
{
((ContainerGridRecord)e.Row).IsEmptyParent = true;
}
Thanks for the reply. How can I set the isparentempty property in the initialize row event?
Well I guess that is the trick here.. Just like the grid does in the automatic mode you would have to ping the child table to see if there are any related child rows for each parent row.
Setting the property oin the parent's InitializeRow should be well in advance of rendering of the indicator.
The only event which seems to expose the isemptyparent property is the rowexpanded event. How would I use this to render the expansion indicator on the initialize row event?
Although I have been able to set up the manual load on demand, I don't understand how I could ever create logic to find children of a row manually (which would mean that I have some piece of info about the parent) and still be able to set the expansion indicator at that point in time. Is the data of the row available to me before the rendering of the expansion indicator?