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
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;