Here I am try to submitting values into sharepoint using createuserwizard Control
I am getting this error: Operation is not valid due to the current state of the object with the following code ....
protected void CreateUserWizard1_CreatedUser1(object sender, EventArgs e) {
try
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite sites = new SPSite("http://choudary:22483/"))
{
using (SPWeb webs = sites.OpenWeb())
{
sites.AllowUnsafeUpdates = true;
webs.AllowUnsafeUpdates = true;
SPList list = webs.Lists["Userdetails"];
SPListItem newItem = list.Items.Add();
newItem["Title"] = CreateUserWizard1.UserName;
newItem["FirstName"] = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FirstName")).Text;
newItem["LastName"] = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("LastName")).Text;
newItem["Organization"] = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Organization")).Text;
newItem["EMail"] = CreateUserWizard1.UserName;
//newItem["Status"] = "Not Started";
//newItem["Priority"] = "Normal";
newItem.Update();
//webs.AllowUnsafeUpdates = false;
//SaveToList();
}
}
});
}
catch (Exception Ex)
{
}
}