using(SPSite site = new SPSite("http://"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["SharePointList"];
SPListItem Item = list.Items.Add();
item["Title"] = txtCompanyName.Text;
//can add required items
item.Update();
}
}
Note: 1. No need to use SPSecurity.RunWithElevatedPrivileges.
2. No need to use allowunsafeupdate property
3. No need to update web object.
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["SharePointList"];
SPListItem Item = list.Items.Add();
item["Title"] = txtCompanyName.Text;
//can add required items
item.Update();
}
}
Note: 1. No need to use SPSecurity.RunWithElevatedPrivileges.
2. No need to use allowunsafeupdate property
3. No need to update web object.