Hello,I have been reading all the post an example about hierarchical webgrid.However, you guys are always using a different method to bind the gridSo what is the most efficient way to bind my hierachical webgrid? (ondatabinding event? page_onload? initializedatasource?)
Keep in mind that I want to do update,insert and delete in my webgrid. By the way, other than the WHDS, you guys did not find any other way to handle CRUD activity more efficiently? I have to write way more code than with the CLR 1.0 to get the CRUD working. The WHDS still has some bug so I have to do it manualy. So if you have any better method please let me know.Thanks and merry christmas
The "most efficient way" is .... it depends. It depends greatly on the type of object you're using for your grid's data source, the nature of the data it contains, and the grid options you're using.
For my personal usage, unless I have a specific reason to do otherwise, I use one of two approaches. One is to assign a data source at design time, such as when I'm using an ASP.NET DataSource control (SqlDataSource, WebHierarchicalDataSource, and so on). If I'm binding to an object in code, I prefer using InitializeDataSource. With either approach, I can easily turn on the grid's AJAX functionality without making significant code changes.
For hierarchical data, if you want to bind at design-time, then WebHierarchicalDataSource is your only viable approach; most of the other ASP.NET DataSource controls (including SqlDataSource and ObjectDataSource) can't handle a hierarchy. If you want to bind in code, you can use the UpdateRow and DeleteRow events (or their batch equivalents) to update your data object, in the same way that was required in a CLR 1.x application.
Thanks for your answer,the problem with using InitializeDataSource is that I do not have anymore control over when the grid get databound.I have a listview and based on the element selected on the listview I refresh my grid.
This works good if I manually bind the datagrid at, Page_unload or ListView1_SelectedIndexChanged. But If I use the InitializeDataSource the grid is always bound to0 early. What I mean is that if I change the selected item in my listview then the grid would always be one selection behind because the grid goes first to the InitializeDataSource and then my ListView1_SelectedIndexChanged get hit which is too late.Would you have a solution for that?Also how can I use the expandall set to true when I use loadOnDemand?
thanks and merry christmas