This is a migrated thread and some comments may be shown as answers.

how to get/set selectedRow in Radgridview

3 Answers 141 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Swathi
Top achievements
Rank 1
Swathi asked on 20 Dec 2010, 10:38 AM
Hi I am using AddingNewDataItem event for radgrid view ,
    But i am unable to delete the selected row.
   also suggest me how to get and set a GridRow.
 
Thanks,
Swathi.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 20 Dec 2010, 10:47 AM
Hello Swathi,

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
Browse the videos here>> to help you get started with RadControls for WPF
0
Swathi
Top achievements
Rank 1
answered on 20 Dec 2010, 11:02 AM
Hi Maya,
            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. 

0
Maya
Telerik team
answered on 20 Dec 2010, 11:39 AM
Hello 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.

Kind regards,
Maya
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
GridView
Asked by
Swathi
Top achievements
Rank 1
Answers by
Maya
Telerik team
Swathi
Top achievements
Rank 1
Share this question
or