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

radgridview multiple insert on save button click

5 Answers 54 Views
GridView
This is a migrated thread and some comments may be shown as answers.
sabha
Top achievements
Rank 1
sabha asked on 17 Dec 2010, 08:59 AM
Hello

I have a radgridview in my form where i want to enter data, but i dont want to execute the submit changes after adding a row
i.e. i want to add say 5 rows and then click a save button and save all 5 rows to the database.
I have been trying hard to get this work but no luck.
Any help will be greatly appreciated.

5 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 17 Dec 2010, 09:08 AM
Hello sabha,

If you are using WCF Ria services and DomainDataSource - this should be available out of the box. You can insert as many rows as needed and they will be submitted to the database once you call the SubmitChanges method of the domain datasource.

If not, you can set the ActionOnLostFocus property of RadGridView to None.

Best wishes,
Veselin Vasilev
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sabha
Top achievements
Rank 1
answered on 18 Dec 2010, 06:08 AM
i tried doing it i am using radcontext menu
and my item click function goes like this
 private void radcontextmenubilling_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadContextMenu menu = (RadContextMenu)sender;
            RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;
            if (clickedItem != null)
            {
                string header = Convert.ToString(clickedItem.Header);
                switch (header)
                {
                    case "Add":
                        this.GridViewBilling.Items.Add(this.GridViewBilling.Items.Count + 1);
                        break;
                    case "Delete":
                        GridViewRow row = menu.GetClickedElement<GridViewRow>();
                        this.GridViewBilling.Items.Remove(this.GridViewBilling.SelectedItem);
                        break;
                }
            }
        }
 private void radcontextmenubilling_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadContextMenu menu = (RadContextMenu)sender;
            RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;
            if (clickedItem != null)
            {
                string header = Convert.ToString(clickedItem.Header);
                switch (header)
                {
                    case "Add":
                        this.GridViewBilling.Items.Add(this.GridViewBilling.Items.Count + 1);
                        break;
                    case "Delete":
                        GridViewRow row = menu.GetClickedElement<GridViewRow>();
                        this.GridViewBilling.Items.Remove(this.GridViewBilling.SelectedItem);
                        break;
                }
            }
        }
 private void radcontextmenubilling_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadContextMenu menu = (RadContextMenu)sender;
            RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;
            if (clickedItem != null)
            {
                string header = Convert.ToString(clickedItem.Header);
                switch (header)
                {
                    case "Add":
                        this.GridViewBilling.Items.Add(this.GridViewBilling.Items.Count + 1);
                        break;
                    case "Delete":
                        GridViewRow row = menu.GetClickedElement<GridViewRow>();
                        this.GridViewBilling.Items.Remove(this.GridViewBilling.SelectedItem);
                        break;
                }
            }
        }
 private void radcontextmenubilling_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadContextMenu menu = (RadContextMenu)sender;
            RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;
            if (clickedItem != null)
            {
                string header = Convert.ToString(clickedItem.Header);
                switch (header)
                {
                    case "Add":
                        this.GridViewBilling.Items.Add(this.GridViewBilling.Items.Count + 1);
                        break;
                    case "Delete":
                        GridViewRow row = menu.GetClickedElement<GridViewRow>();
                        this.GridViewBilling.Items.Remove(this.GridViewBilling.SelectedItem);
                        break;
                }
            }
        }
 private void radcontextmenubilling_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadContextMenu menu = (RadContextMenu)sender;
            RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;
            if (clickedItem != null)
            {
                string header = Convert.ToString(clickedItem.Header);
                switch (header)
                {
                    case "Add":
                        this.GridViewBilling.Items.Add(this.GridViewBilling.Items.Count + 1);
                        break;
                    case "Delete":
                        GridViewRow row = menu.GetClickedElement<GridViewRow>();
                        this.GridViewBilling.Items.Remove(this.GridViewBilling.SelectedItem);
                        break;
                }
            }
        }
 private void radcontextmenubilling_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadContextMenu menu = (RadContextMenu)sender;
            RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;
            if (clickedItem != null)
            {
                string header = Convert.ToString(clickedItem.Header);
                switch (header)
                {
                    case "Add":
                        this.GridViewBilling.Items.Add(this.GridViewBilling.Items.Count + 1);
                        break;
                    case "Delete":
                        GridViewRow row = menu.GetClickedElement<GridViewRow>();
                        this.GridViewBilling.Items.Remove(this.GridViewBilling.SelectedItem);
                        break;
                }
            }
        }
 private void radcontextmenubilling_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadContextMenu menu = (RadContextMenu)sender;
            RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;
            if (clickedItem != null)
            {
                string header = Convert.ToString(clickedItem.Header);
                switch (header)
                {
                    case "Add":
                        this.GridViewBilling.Items.Add(this.GridViewBilling.Items.Count + 1);
                        break;
                    case "Delete":
                        GridViewRow row = menu.GetClickedElement<GridViewRow>();
                        this.GridViewBilling.Items.Remove(this.GridViewBilling.SelectedItem);
                        break;
                }
            }
        }
 private void radcontextmenubilling_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            RadContextMenu menu = (RadContextMenu)sender;
            RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;
            if (clickedItem != null)
            {
                string header = Convert.ToString(clickedItem.Header);
                switch (header)
                {
                    case "Add":
                        this.GridViewBilling.Items.Add(this.GridViewBilling.Items.Count + 1);
                        break;
                    case "Delete":
                        GridViewRow row = menu.GetClickedElement<GridViewRow>();
                        this.GridViewBilling.Items.Remove(this.GridViewBilling.SelectedItem);
                        break;
                }
            }
        }

private void radcontextmenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)

        {

            RadContextMenu menu = (RadContextMenu)sender;

            RadMenuItem clickedItem = e.OriginalSource as RadMenuItem;

            if (clickedItem != null)

            {

                string header = Convert.ToString(clickedItem.Header);

                switch (header)

                {

                    case "Add":

                        this.GridViewB.Items.Add(this.GridViewB.Items.Count + 1);

                        break;

                    case "Delete":

                        GridViewRow row = menu.GetClickedElement<GridViewRow>();

                        this.GridViewB.Items.Remove(this.GridViewB.SelectedItem);

                        break;

                }

            }

        }

whenver i click add, enter data and move to other cell the value doesnt remain in the cell(the cell will be blank).
0
Vlad
Telerik team
answered on 20 Dec 2010, 08:57 AM
Hello,

 Can you post more info how the grid is bound in your case? What kind of collection and objects you are using?

Kind regards,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sabha
Top achievements
Rank 1
answered on 21 Dec 2010, 06:17 AM
Hello Vlad 

thanks for your reply
ok i made some change in the following line 
this.GridViewB.Items.Add(this.GridViewB.Items.Count + 1);
as
this.GridViewB.Items.Add(new BILL());
now it is fine. the items stay in the grid.
I am using two way binding for the datacolumn items in the radgridview.
And onrowedit ended
for insert case
i am moving the contents of each row into the list of the BILL object.
and on save button click i am using foreach loop to insert all the objects in the list.
this works fine for insert but this doesnt work for edit and delete.
Any suggestions
0
Yogish
Top achievements
Rank 1
answered on 11 Mar 2011, 12:49 PM
how to add multiple items using radgridview. and using master table id if fill the rad gridview and once again if i goes to add new row it shows edit or update not valid while itemsource in use? please answer to this two question.   regards yogish m shetty
Tags
GridView
Asked by
sabha
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
sabha
Top achievements
Rank 1
Vlad
Telerik team
Yogish
Top achievements
Rank 1
Share this question
or