Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using Sharepoint 2010 Data Services to create items on a table.

My table has a column called Priority which has High, Medium, and Low items in it.

When I try to create an item in this table via listdata.svc service in c#, Priority field value is not submitted, but the ticket is created on the server. My code is below:

TicketItem obj = new TicketItem();
obj.Title = "test";
IMGCustomerPortalDataContext dataContext = new IMGCustomerPortalDataContext(new Uri("http://server/site/_vti_bin/listdata.svc", UriKind.Absolute));
dataContext.Credentials = System.Net.CredentialCache.DefaultCredentials;
///Tried both of them
//obj.Priority = dataContext.TicketPriority.Where(k => k.Value == "Low").First();
obj.Priority = TicketPriorityValue.CreateTicketPriorityValue("Low");
dataContext.AddToTicket(obj);
dataContext.SaveChanges();

Is there anything I am missing?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

after a detailed research I have figured this out.

the link between objects needs to be set explicitly

So, the line below sorted it...

dataContext.SetLink(obj, "Priority", pri);

or

ticket.PriorityValue = "Low";

did the same job...

share|improve this answer
    
Can u give Final code for the above Thanks –  user16588 Apr 24 '13 at 13:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.