here is the way that you can get the view in your list
using (SPSite site = new SPSite(yoursiteUrl))
{
if (site != null)
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["ListName"];
if (list != null)
{
SPListItemCollection coll = web.Lists["ListName"].GetItems(web.Lists["ListName"].Views["ViewName"]);
foreach (SPListItem item in coll)
{
//do something
//if you are testing on console application
Console.WriteLine(item.Title.ToString());
}
}
web.Close();
}
site.Close();
}
}
using (SPSite site = new SPSite(yoursiteUrl))
{
if (site != null)
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["ListName"];
if (list != null)
{
SPListItemCollection coll = web.Lists["ListName"].GetItems(web.Lists["ListName"].Views["ViewName"]);
foreach (SPListItem item in coll)
{
//do something
//if you are testing on console application
Console.WriteLine(item.Title.ToString());
}
}
web.Close();
}
site.Close();
}
}
Regards
Rashid Imran Bilgrami
Comments
Post a Comment