views:

13

answers:

0

Hi all, I have two field in datagrid C#.net window. One is items which is dropdownlist(all the items from item tables is poped up and another quantity which which is text box type user can enter the quantity in that. I want whatever item selected and whatever quantity entered in datagrid all these will be saved in backend table using webservice insertmethod. I am trying to loop thru in datagrid but getting type conversation error like…

Unable to cast object of type 'System.String' to type 'Create_Sales_Back_Order.DynamicsGPService.SalesBackorder'. Here is my looping code:

// Create an instance of the service DynamicsGP wsDynamicsGP = new DynamicsGP(); Context context=context = new Context(); // Set up the context object context.OrganizationKey = (OrganizationKey)companyKey;

SalesBackorder salesBackorder= new SalesBackorder(); SalesBackorderLine salesBackorderLine = new SalesBackorderLine(); 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;

for (int counter = 0; counter < (CreateSalesBackOrderGrid.Rows.Count); counter++) { salesBackorder = (SalesBackorder)CreateSalesBackOrderGrid.Rows[counter].Cells[0].Value; salesBackorderCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesBackorder", context); wsDynamicsGP.CreateSalesBackorder(salesBackorder, context, salesBackorderCreatePolicy);

}