Hi All,
I am handling some code these days.And I had written managed code as below and every thing looks fine in the code.But facing the error
"The property or field has not been initialized. It has not been requested or the requested has not been executed.It may need to be explicitly requested"
And below is the image,I went back and checked the list and column name which is fine .But couldn't find the issue,Can any one help me in knowing why the property or filed of the list is not being initializing.
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
namespace Exims.VisualWebPart1
{
public partial class VisualWebPart1UserControl : UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack!=true)
{
txtcategories.Text = "";
}
}
protected void txt_Click(object sender, EventArgs e)
{
if (txtcategories.Text != null)
{
string sitename = "http://sp2010:27199/sites/Sample";
ClientContext mysite = new ClientContext(sitename);
List mylist = mysite.Web.Lists.GetByTitle("Categories");
ListItemCreationInformation myitemcreation = new ListItemCreationInformation();
Microsoft.SharePoint.Client.ListItem myitem = mylist.AddItem(myitemcreation);
myitem.Update();
myitem["ProductCategories"] = txtcategories.Text.ToUpper();
mysite.ExecuteQuery();
lblmsg.Text = "Item Added Successfully";
}
else
{
lblmsg.Visible = true;
lblmsg.Text = "Enter Category";
}
}
Thanks, Quality Communication Provides Quality Work. http://siddiq-sharepoint2010.blogspot.in/ Siddiqali Mohammad .