troubleshooting Question

Value does not fall in the expected range

Avatar of mshaji
mshajiFlag for India asked on
Microsoft SharePoint
6 Comments2 Solutions1880 ViewsLast Modified:
I have SharePoint blog in English and Arabic language versions. By C# code i inserted successfully a new item to Blog post. But while I try to insert a new item in the Arabic version then its giving error: Value does not fall within the expected range.

Is there any setting I have to change in here. Please see my code here.

string DURL = "http://mysite/Arabic/Blog1/Lists/Posts/";
            using (SPSite site = new SPSite(DURL))
              using (SPWeb web = site.OpenWeb())

                web.AllowUnsafeUpdates = true;
                SPList list = web.Lists["Posts"];

                SPUser user = web.EnsureUser(HttpContext.Current.User.Identity.Name);
                SPListItem Item1 = list.Items.Add();
                Item1["Title"] = TxtTitle.Text;
                Item1["Body"] = TxtBody.Text;
                Item1.Fields["Created By"].ReadOnlyField = false;

                Item1["Published"] = System.DateTime.Now;
                string userValue = user.ID + ";#" + user.Name;
                Item1["Created By"] = userValue;
                Item1.Fields["Created By"].ReadOnlyField = true;

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros