Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 获取sharepoint列表的可用视图并填充到dropdownlist?_Asp.net_C# 4.0_Sharepoint 2010 - Fatal编程技术网

Asp.net 获取sharepoint列表的可用视图并填充到dropdownlist?

Asp.net 获取sharepoint列表的可用视图并填充到dropdownlist?,asp.net,c#-4.0,sharepoint-2010,Asp.net,C# 4.0,Sharepoint 2010,我在sharepoint列表中创建了视图,但是在上面的代码中 在循环时,我正确地获得了视图名,但在填充到 下拉列表显示了我获得的类似Microsoft.Sharepoint的输出 安装视图名 1. Here the sample code i tried for getting the available views for the sharepoint list and populating into the dropdownlist

我在sharepoint列表中创建了视图,但是在上面的代码中 在循环时,我正确地获得了视图名,但在填充到 下拉列表显示了我获得的类似Microsoft.Sharepoint的输出 安装视图名

             1. Here the sample code i tried for getting the available views for the
                sharepoint list and populating into the dropdownlist

          protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    SPSite site = new SPSite(SPContext.Current.Site.Url);
                    foreach (SPWeb web in site.AllWebs)
                    {
                        SPListCollection spListCollection = web.GetListsOfType(SPBaseType.GenericList);

                        foreach (SPList splist in spListCollection)
                        {
                            ListNameList.Items.Add(splist.Title.ToString());                        
                        }
                        ListNameList.Items.Insert(0, "--Select--");

                    }
                }
}

                       protected void ListNameList_SelectedIndexChanged(object sender,EventArgs e)
                           {
                            SPSite site = new SPSite(SPContext.Current.Site.Url);
                            SPWeb web = site.OpenWeb();
                            SPList selectedlist = web.Lists[ListNameList.SelectedValue];
                            foreach (SPView views in selectedlist.Views)
                            {
                                ViewNameList.Items.Add(views.Views.ToString());
                            }
                          }

我认为您只需要编辑将新项目添加到ViewName列表中的行即可使用view.Title

    Can you help me out of this?
如果集合没有按您想要的顺序返回视图,您可能还需要对视图进行排序。

是否应该在“ViewNameList.Items.Add(views.views.ToString());“be”views.Title行中添加?
protected void ListNameList_SelectedIndexChanged(object sender,EventArgs e)
{
    SPSite site = new SPSite(SPContext.Current.Site.Url);
    SPWeb web = site.OpenWeb();
    SPList selectedlist = web.Lists[ListNameList.SelectedValue];
    foreach (SPView views in selectedlist.Views)
    {
        ViewNameList.Items.Add(views.Title);
    }
}