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);
}
Pls……………pls……………pls………….help me..
Sam HobbsPosted Sep 25, 2010, 1:10 PM
So the cell is not a SalesBackorder object but I don't know why it is not and based on the code here I doubt that anyone knows why it is not. How is the column set to a SalesBackorder object? Note also that it helps to post all relevant code without posting a lot of irrelevant code. If you post too much code, no one will try to help.