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

Remove Row

4 Answers 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eduardo
Top achievements
Rank 1
Eduardo asked on 23 Mar 2009, 12:19 PM
how to remove the selected row?
I tryed this:

grid.Items.Remove(grid.SelectedItem);

...but it isn't work

4 Answers, 1 is accepted

Sort by
0
Eduardo
Top achievements
Rank 1
answered on 23 Mar 2009, 08:36 PM
it's works:

grid.SelectedRecord.RecordManager.DeleteRecord(grid.Records.IndexOf(grid.SelectedRecord));

...but, this is the best way?

 

0
Vlad
Telerik team
answered on 24 Mar 2009, 09:23 AM
Hi Eduardo,

Can you post more info about how the grid is bound in your case?

Sincerely yours,
Vlad
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Eduardo
Top achievements
Rank 1
answered on 24 Mar 2009, 11:24 AM

        // -> UI Constructor
        public UIContry
        {
            InitializeComponent();
            LoadGrid();
        }

        private void LoadGrid()
        {
            ServiceFactory session = new ServiceFactory();
            session.ExecuteServiceMethod<ConsultService.LoadDataGridCompletedEventArgs>(typeof(ConsultServiceClient).FullName, LoadDataGridCompleted, "LoadDataGrid", "Country", "");
        }

        void LoadDataGridCompleted(object sender, LoadDataGridCompletedEventArgs e)
        {
            grid.DataBind(e.Result); // -> Extension method, e.result as a byte[]
        }

        // -> Extension Method of the RadGridView
        public static void DataBind(this RadGridView grid, byte[] data)
        {
            // DataSet re-implemented (by ComponentOne)
            MemoryStream str = new MemoryStream(data);
            DataSet ds = new DataSet("DS");
            ds.ReadXml(str);
            ds.AcceptChanges();

            grid.AutoGenerateColumns = false;
            grid.ItemsSource = ds.Tables[0].DefaultView;
        }

...this is populing the grid, but I want to click in the any button and remove (local) any row...
ComponentOne do it: grid.RemoveRow(grid.SelectedRow);

0
Accepted
Vlad
Telerik team
answered on 24 Mar 2009, 11:37 AM
Hi Eduardo,

Here is an example:

            DataView view = (DataView) RadGridView1.ItemsSource;
            view.Remove(RadGridView1.SelectedItem);



All the best,
Vlad
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Eduardo
Top achievements
Rank 1
Answers by
Eduardo
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or