I am creating a list with a deployed list template. with the following code:
SPSite site = new SPSite("http://servername");
SPWeb web = site.OpenWeb();
web.Lists.Add(listName, listName, listTemplate);
web.Update();
SPList List = Web.Lists[listName];
I am able to access the list with the web
object which is used to create it. But, SPContext.Current.Web
is not updated. So, the following throws error:
SPContext.Current.Web.Lists[listName]
Is it possible to update the SPContext.Current
object with latest information so that the list accessible after it is created?
Thanks in advance!
Update: Code updated.