It appears there is some kind of issue with calling ClearDataSource on a postback and the presence of the "Multiple controls with the same ID error" being thrown when a Template control exists in the WebDataGrid.
I have a template column with a checkbox and if I use the ClearDataSource call before rebinding the WebDataGrid on a postback I get the "Multiple controls..." error presumably related to the checkbox. If I comment out the ClearDataSource my postback works just fine and I don't get the fatal error but then, even though I'm rebinding the WebDataGrid (with a refreshed object List<T> collection pulled from the db) on the postback, the OnInitializeRow event handler does not fire again - it will fire on the intiial page load and that's it - which also is a problem as I set some custom cell tooltips when the InitializeRow event is fired - seem's I'm darned if I do, and darned if I don't. Anyone have any thoughts.
Hello,
Do you have this piece of code for c# please?
Thanks.
It worked fine!!
thanks x 1000
We've been running into the same problem using v10.3 SR 2134.
To workaround the issue we've added the following extra WebDataGrid clearing logic (inside the 'doExtraClearingLogic' if block) to be executed only during the re-binds that were causing us to receive the multiple controls with the same ID errors.
grdSelectedHorse.Rows.Clear()grdSelectedHorse.ClearDataSource()If doExtraClearingLogic Then Dim templateControlContainer As PropertyInfo = grdSelectedHorse.GetType.GetProperty("TemplateContainerControl", Reflection.BindingFlags.GetProperty Or Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic) DirectCast(templateControlContainer.GetValue(grdSelectedHorse, Nothing), Control).Controls.Clear()End IfgrdSelectedHorse.DataSource = listgrdSelectedHorse.DataBind()
Note: 'grdSelectedHorse' is our WebDataGrid & 'list' is a Generic.List of anonymous typed objects in our case
Hope this helps someone!
Hi,
It is strange in my case.
When on local development machine, I try to open the page it gives me same id error.
Then I access the development server from a remote machine, the page opens with no problem.
Then I open locally and now it opens...
I tried grid.rows.clear() it worked now, but I do not know it is beacuse I first logged from a remote
machine or not... (my version is 10.V3.2120)
Cheers
I have the same problem with WebDataGrid Version=10.3.20103.2073, and the DataBind code below
private void BindData()
{ this.WebDataGrid1.Rows.Clear(); this.WebDataGrid1.ClearDataSource(); this.WebDataGrid1.DataSource = this.ods_DataPointValueSet.Select(); this.WebDataGrid1.DataBind(); //this.WebDataGrid1.DataSourceID = "ods_DataPointValueSet"; //.DataSource = this.ods_DataPointValueSet.Select(); }