Accessing SPList Object using web.Lists method
SPList listObj = webObj.Lists["DataTypes"];
int itemcount = listObj.ItemCount;
Accessing SPList Object using web.GetList method
SPList listObj2 = webObj.GetList(webObj.ServerRelativeUrl.TrimEnd('/') + "/Lists/DataTypes");
int itemcount2 = listObj2.ItemCount;
Some times we may change the list name after creating the list. In that case web.Lists accessing method gives error. So better to adopt GetList method when accessing lists.
SPList listObj = webObj.Lists["DataTypes"];
int itemcount = listObj.ItemCount;
Accessing SPList Object using web.GetList method
SPList listObj2 = webObj.GetList(webObj.ServerRelativeUrl.TrimEnd('/') + "/Lists/DataTypes");
int itemcount2 = listObj2.ItemCount;
Some times we may change the list name after creating the list. In that case web.Lists accessing method gives error. So better to adopt GetList method when accessing lists.
No comments:
Post a Comment