Hi all !I've created an example with a WebGrid with hierarchical data as described in the article
http://help.infragistics.com/NetAdvantage/NET/Current/CLR2.0/?target=WebGrid.html
The example works fine, but when trying to access the child band, an exception will be thrown.
this.UltraWebGrid1.Band[0].Columns.All // works fine this.UltraWebGrid1.Band[1].Columns.All // throws an exception
It seams, that the child band is absolute unknown for the WebGrid, because calling
this.UltraWebGrid1.Bands.Count returns 1, and not 2 !
Any hint or idea is welcome. Thanks in advance.
Regards,Claus
The link you've provided leads to a landing page, so I'm not sure which article you're using as your guide.
When are you checking this value? Are you databinding the grid?
Most likely, at the time you're checking this value, the second band may not exist yet.
Hi !
Sorry, the correct link is:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/WebHierarchicalDataSource_Getting_Started_with_WebHierarchicalDatasource.html
In the Page_Load event I tried to access the root band and child band. But the child band doesn't exist in WebGrid.
protected void Page_Load(object sender, EventArgs e) {
if (!Page.IsPostBack) { // this.UltraWebGrid1 this.UltraWebGrid1.Bands[0].Columns[0].Hidden = true; this.UltraWebGrid1.Bands[1].Columns[0].Hidden = true; } }
if (!Page.IsPostBack) { // this.UltraWebGrid1 this.UltraWebGrid1.Bands[0].Columns[0].Hidden = true; this.UltraWebGrid1.Bands[1].Columns[0].Hidden = true; }
}
Regards.
Claus
OK, that helps to understand what you're working with.
Where are you looking up these values? If the grid had finished databinding, I'd expect there to be no exception, but if you did it too early (such as an Init event?), I'd expect this exception to be thrown.
A good suggestion for making any changes or queries to the bands and/or columns in databound WebGrid is to do so in the InitializeLayout event handler. Use "e.Layout.Bands" instead of the grid's direct Bands collection or its "DisplayLayout.Bands" property - each will lead to the same end result, but using e.Layout.Bands provides code that can be reused more easily.
I have worked with the new WebDataGrid a little, and the first release of it will not support Hierarchical data, but it is on the wish list. Let's hope they improve the WHDS soon.
Don
@PsychoTeddy
If you are using WebHierarchicalDataSource as data source for the WebGrid, you can reproduce the described behavior. Please read http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/WebHierarchicalDataSource_Getting_Started_with_WebHierarchicalDatasource.html)
Regards,
The WebGrid supports hirarchical data and it does it pretty well, it just doesn't support some sort of previewing the data in design time, but most business apps set their datasources dynamically at runtime, so for me this feature isn't such a big deal and I'm sure there's more important subjects to work on. Plus, I've heard of the new WebDataGrid and then we'll see how much of an improvement we can find there.
In typical business applications most existing data is hierarchical by nature. Therefore, displaying hierarchical data should be a must criteria for every ASP.Net control framework !!