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

How to add remove/cancel button to row

3 Answers 139 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Daniel Billingsley
Top achievements
Rank 1
Daniel Billingsley asked on 21 Jun 2010, 04:42 PM
I have a GridView with custom columns, including a final one of type GridViewColumn.  I've placed a button in that column via its CellTemplate.

I'd like to remove the row when the user clicks on that button.  I've seen the examples of how to get a reference to the row containing the button that was clicked, but how do I remove the row (including delete from the underlying bound data source)?

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 21 Jun 2010, 05:07 PM
Hi Daniel Billingsley,

Please let me know what  is the type of the underlying data source and I will paste you a piece of code to do the trick. e.g. what kind of collection do you set as IttemsSource for RadGridView ? .

Regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Daniel Billingsley
Top achievements
Rank 1
answered on 22 Jun 2010, 01:48 PM
I took this sort of crude approach in the handler for the click event on the button in the grid row:

private void RemoveButton_Click(object sender, RoutedEventArgs e)
{
    RadButton btn = e.OriginalSource as RadButton;
    if (btn != null)
    {
        var row = btn.ParentOfType<GridViewRow>();
        row.IsSelected = true;
        // my code here now uses the SelectedItem property of the GridView
    }
}


Do you see any problem with that?  It seems to work perfect.
0
Pavel Pavlov
Telerik team
answered on 22 Jun 2010, 01:50 PM
Hi Daniel Billingsley,

It is just OK .

Best wishes,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Daniel Billingsley
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Daniel Billingsley
Top achievements
Rank 1
Share this question
or