List out All Views for a SharePoint List
public void RetrieveViews()
{
try
{
using (SPSite osite = new SPSite("SiteURL") )
{
using (SPWeb oweb = osite.OpenWeb())
{
SPList olist = oweb.Lists[ListName];
if (olist != null)
{
SPViewCollection oviewCollection = olist.Views;
foreach (SPView oview in oviewCollection)
{
ComboBox1.Items.Add(oview.Title);
}
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("RetrieveViews() "+ex.Message);
}
Comments
Post a Comment