Namespace used:
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
Code:
SPWeb currentWeb = SPControl.GetContextWeb(Context);
SPList states = currentWeb.Lists["States"]; //If this line commented then not
getting the error
Error:
System.ArgumentException: Value does not fall within the expected range. at
Microsoft.SharePoint.SPListCollection.GetListByName(String strListName, Boolean
bThrowException) at Microsoft.SharePoint.SPListCollection.get_Item(String
strListName) at StatesAndCities.Page_Load(Object sender, EventArgs e); Message:
Value does not fall within the expected range.
Please anyone help me, why i am getting this error, am i doing wrong. Can I get
any code to get all items (columns) from a list.