I'm binding a WebDataGrid on a OnSelectedIndexChanged event which works fine. However I'm using an UnboundCheckBoxField and if I select checkbox in the header, then deselect one or more rows, and change the selection from the dropdownlist, I get the above error.
I am not concerned with keeping previously checked values so I just clear DataSource, dehydrate, and rebind.
protected void serviceTypeFamilyDropDown_OnSelectedIndexChanged(object sender, EventArgs e)
{ using (DropDownList serviceTypeFamilyDropDown = sender as DropDownList) { servicesGrid.ClearDataSource(); servicesGrid.DataSource = ExportableServiceVisits.GetServiceVisitsByServiceTypeFamily( serviceTypeFamilyDropDown.SelectedItem.Value.GetDoubleOrIntValue<int>(), serviceDatePicker.Date); servicesGrid.DataBind(); }}
Following suggestions from this forum I created a property on the page and upon OnSelectedIndexChanged I updated the data of the property then on servicesGrid_OnPreRender, I cleared the DataSource, set the DataSource to the property and rebound. However, the error was thrown before OnPreRender() was executed.
private IEnumerable<ExportableServiceVisits> ServiceVisits { get; set; }
protected void serviceTypeFamilyDropDown_OnSelectedIndexChanged(object sender, EventArgs e){ using (DropDownList serviceTypeFamilyDropDown = sender as DropDownList) { ServiceVisits = ExportableServiceVisits.GetServiceVisitsByServiceTypeFamily( serviceTypeFamilyDropDown.SelectedItem.Value.GetDoubleOrIntValue<int>(), serviceDatePicker.Date); }}
protected void servicesGrid_OnPreRender(object sender, EventArgs e){ servicesGrid.ClearDataSource(); servicesGrid.DataSource = ServiceVisits; servicesGrid.DataBind();}
What's the problem?
Hello Kyle,
I couldn't reproduce the issue. Please send me an isolated working sample to see what exactly is the problem.
I'm looking forward your reply.