retrieve sharepoint list data c#
Retrieve sharepoint list data using c#(server object model):
First insert the following name space
using Microsoft.SharePoint;
Use the following code to retrive list data
protected void Page_Load(object sender, EventArgs e)
{
SPSite site = SPContext.Current.Site;
SPWeb web = SPContext.Current.Web;
SPList listobj = web.Lists["ListName"];
SPQuery qry = new SPQuery();
qry.Query = "<view/>";
SPListItemCollection _icoll = listobj.GetItems(qry);
foreach (SPListItem item in _icoll)
{
Label1.Text += Convert.ToString(item["ColumnName"]);
}
}
If you want to bind it to a GridView then see this GridView simple example , Clickable/Databound in GridView
Comments
Post a Comment