Problem with inserting value in table

Sep 23 2010 11:12 AM

Hi

 Using webservice method I wanted to insert multiple row in database table. Though I am passing more than one row its inserting only one row. Could somebody please help me how can do this. And one more after inserting the records I wanted clear the datagrid cell but that is also not working… Here is my code:


// Create a sales backorder line to specify the backordered item

            SalesBackorderLine salesBackorderLine = new SalesBackorderLine();

 

             // Create an item key

            ItemKey itemKey = new ItemKey();        

 

            itemKey.Id = itemnumber;          

 

            // Populate the item key property of the sales invoice line object

            salesBackorderLine.ItemKey = itemKey; 

            // Create a sales backorder quantity object

            Quantity backorderCount = new Quantity();

            backorderCount.Value =Convert.ToDecimal(quantity); 

            // Populate the quantity of the sales backorder line object

            salesBackorderLine.Quantity = backorderCount;           

            // Create an array of sales backorder objects

            // Initialize the array with the sales backorder line object

            SalesBackorderLine[] backorderLines = { salesBackorderLine };

            // Add the sales backorder line array to the sales backorder object

            salesBackorder.Lines = backorderLines;                                

            try

            {

                // Get the create policy for sales backorder objects

                salesBackorderCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesBackorder", context);

                 // Create the sales backorder

                wsDynamicsGP.CreateSalesBackorder(salesBackorder, context, salesBackorderCreatePolicy);

       //this code not clearing the datagrid also…..

                for (int i = 0; i <= CreateSalesBackOrderGrid.Rows.Count - 1; i++)  

                {

                    CreateSalesBackOrderGrid.Rows[i].Cells.Clear();

                }

                

            }

            catch (Exception ex)

            {

                MessageBox.Show(ex.Message.ToString());

            }

 

        }