hi,
I have a problem with WebHierarchicalDataGrid inside an UpdatePanel. I want to refresh the panel (and reload the grid data from the db) with a button click. This generally works, but if i expand some detail rows (manual load on demand) i get an error if i want to reload the grid. I did the same thing with UltraWebGrid (working), but i have to switch to WebHierarchicalDataGrid for better browser support.
[InvalidOperationException: Collection was modified; enumeration operation may not execute.] System.Web.UI.ControlCollectionEnumerator.MoveNext() +8798722 Infragistics.Web.UI.GridControls.ContainerGrid.EnsureChildControls() +783 System.Web.UI.Control.PreRenderRecursiveInternal() +42 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Control.PreRenderRecursiveInternal() +175 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496I'm attaching a sample project to demonstrate the problem. Steps to reproduce:1) click "Load" button.2) expand a detail row on the grid.3) click "Load" button -> error
Hi pfendt,
This exception looks exactly like the symptom of bug 88806 to me. This has been fixed already. It should make its way into one of the next Service Releases. I would contact Developer Support to to have your case attached to the bug.
regards,David Young
I got it working by handling the InitializeBand event. It would be REALLY nice to have some documentation about what stuff is in the viewstate and what stuff i have to set on each postback. For now i'm mostly guessing and the error messages are not really helpful (maybe i'm missing something?).
My next problem is that i added some custom template columns, and they disappear after postback (eg reloading the grid or clicking on a header to sort). I'm setting them in the InitializeBand event, so it should work.
attaching new sample.
hmm, i have to generate the columns dynamically (dependent on database values).
to be clear, where is the preferred place to init/set columns?
init (add) columns: onLoad(not postback)
update colums (header, template, etc): initbands or onload(postback) ? providing the bug with onload and modified collections is fixed.
Hello Wilhelm,Every time a postback occurs and flushes your columns. So in every postback your columns are flushed and you have to remake and reasign them to the grid in "OnLoad" function.
Nikifor Tsvetkov"] So in every postback your columns are flushed and you have to remake and reasign them to the grid in "OnLoad" function
remake? but the columns are still there on postback (just with some values missing .. again, it would be nice to know what data survives a postback and what not), do i have to clear them first?
anyway .. now i set the templates and column header on each postback, the template buttons still disappear. i even tried to clear the columns and readd them every postback, this does not make any difference.
attaching new sample
Hello Wilhelm,Please take a look at the followin tutorial of using Item Template http://help.infragistics.com/Help/NetAdvantage/ASPNET/2010.3/CLR4.0/html/WebHierarchicalDataGrid_Using_Item_Template.html I hope it will be helpfull for you to design your template column adding properly.
I'm sorry, but this is not working at all. If i use the the RowIslandDataBinding event handler the template columns do not show up at all. Not to mention that in the sample they do not set the itemtemplate on postback, so this could not work ever because itemtemplate is always nothing on postback.
Your code and the code you linked to simply does NOT work.
1) use your code: duplicate column key (because the columns don't get deleted on postback). if i clear() the columns first, nothing is shown.
2) use linked code: does not work because it sets columns only in inital post and not on postback ... template columns get set to nothing and disappear. the linked sample code can never work with postbacks because of this.
after a LOT of time wasted if finally found a solution. I'm using your posted code, clearing the columns collection before adding them anew. The important part is, I'm adding the columns to the GridView now, this seems to be the only way to make this work.
please check/update your sample codes to actually make them work.
Hello,
Please let me know if you have any further questions regarding this issue.
Hello WilhelmThe in your code you have forgotten to add the column in the event so it should look like this:
Private Sub WebHierarchicalDataGrid1_RowIslandDataBinding(sender As Object, e As Infragistics.Web.UI.GridControls.RowIslandEventArgs) Handles WebHierarchicalDataGrid1.RowIslandDataBinding
If e.RowIsland.DataMember = WebHierarchicalDataGrid1.DataMember Then
()
field1.Key =
"TemplateColumn1"
field1.Header.Text =
"haha"
.WebHierarchicalDataGrid1.Columns.Add(field1)
)
templateColumn1.ItemTemplate =
);
'itemplate = DirectCast(WebHierarchicalDataGrid1.Columns.FromKey("button2"), TemplateDataField)
'itemplate.ItemTemplate = New ButtonTemplate("hehe", "cmdB")
If
Sub
d At the moment this code wont work and when expandign will give you Async error. This is known issue and it is fixed, tested and awaits release. The next service release in which it will be solved is with scheduled date 9 November but note this date always may be changed due to unforeseen circumstances.
Hello Wilhelm,I am still investigatin the issue. I will update you with information withing the next few days.