Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Value does not fall in the expected range

Avatar of mshaji
mshajiFlag for India asked on
Microsoft SharePoint
6 Comments1 Solution1880 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;
Avatar of game-master
game-masterFlag of Philippines image

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

This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers