3 Answers, 1 is accepted
The ability to insert and delete items depends on the type of collection you use as data source for the grid. Basically, you need to implement either IList or EditableCollection. However, in order to provide you a more specific solution, I would need a bit more details about your particular scenario and settings.
Considering you second requirement, what exactly do you mean of getting and setting a row ? Do you want to get the underlaying item ? In this case you may use the Items collection of the grid.
All the best,
Maya
the Telerik team
Thanks for the reply,
Actually i am binding the gird using IListSource (attributesDataGrid.ItemsSource = ((IListSource)attributesDT).GetList();)
and i have registered an event addingNewdataItem,to validate prev.row before inserting new row.
for the first time i am able to delete the row and the next time its not allowing me to delete .Here is my code
private void OnAttributesGridAddingNewDataItem(object sender, GridViewAddingNewEventArgs e)
{
if (this.attributesDT.Rows.Count == 0) {
e.Cancel = false;return;
}if (this.attributesDataGrid.SelectedItem == null || !ValidateAttributesGrid((DataRowView)this.attributesDataGrid.SelectedItem))
e.Cancel =
true;}
I did not register any event for deletion.
Thanks,
Swathi.
Basically, you should experience no problem when working with IListSource and insertion and deletion of the items should be possible. Do you do anything more specific - do you handle some other events for example ? Any relevant information would be helpful. It would be great if you could send us a sample project so that I could see your exact requirements.
Considering the validation of the items, you may use the RowValidating and RowValidated events of the RadGridView.
Maya
the Telerik team