Inserting list item Sharepoint 2010 using listdata.svc REST on ASP .net

Posted: February 3, 2012 in web

on postback. be sure to update your reference if you want to add/edit sp list under App_WebReference

tmpDataContext tmpContext = new tmpDataContext(new Uri("http://example.com/_vti_bin/ListData.svc"));
  tmpContext.Credentials = GetNetworkCredential(); //user method
        string Name = HttpContext.Current.Request.Form["PersonName"];
        string ItemType = HttpContext.Current.Request.Form["ctype"];
        string Comments = HttpContext.Current.Request.Form["cComments"];
        string lat = HttpContext.Current.Request.Form["lat"];
        string lng = HttpContext.Current.Request.Form["lng"];
        string location = HttpContext.Current.Request.Form["enterlocation"];

        if(HttpContext.Current.Request.Form["selectlocation"] == "current")
             location =  "http://maps.google.com/maps?q=" + lat + "," + lng;

        tmpContext.AddToFeedback(
            new FeedbackItem
            {
                Title = Name,
                ItemType = ItemType,
                Comments = Comments,
                Location = location
            });
        tmpContext.SaveChanges();
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s