1
Answer

[WPF] DataGrid and Refresh during AddNew o EditItem

Hi,
in my DataGrid, the user can add a new row with a button that add an empty item in collection that is in bind with DataGrid.

The first column of DataGrid is a CheckBox Column, if the user add a NewRow and click on CheckBox Column for select/deselect all items I have an error:

"'Refresh' non consentito durante una transazione AddNew o EditItem."

My code is:
private void HeadCheck(object sender, RoutedEventArgs e, bool IsChecked)
{
var items = dgPlan.Items.OfType<AnalysisPlanItemExt>();
foreach (var item in items)
{
item.IsChecked = IsChecked;
}

try
{
dgPlan.Items.Refresh();
}
catch (Exception ex)
{
dgPlan.CancelEdit(DataGridEditingUnit.Row);
dgPlan.Items.Refresh();
}
}
I added a try-catch but the error there is still.

Thanks.

Answers (1)

0
Photo of alex alex
NA 27 647 8y
I need more details,would you please make some changes on sample which has been sent to you?
0
Photo of Saineshwar Bageri
NA 20.1k 11.2m 8y
 Do in Document.ready function of Jquery.
 
1. Bind main dropdownlist and provide ID of dropdownlist selected from Model.
2. then if first dropdownlist is selected then call your ajax script Document.ready function in to bind  Second dropdownlist and then to set selected values just get value from Model and set it.
 
 Reference :-
http://www.c-sharpcorner.com/UploadFile/4d9083/filter-webgrid-with-cascading-dropdownlist-along-with-paging/