在包含列表文档的Sharepoint中创建一个下拉列表,其中包含指向它们的链接 [英] Create a dropdown list in Sharepoint containing List Documents with links to them

查看:170
本文介绍了在包含列表文档的Sharepoint中创建一个下拉列表,其中包含指向它们的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的default.aspx页面上创建一个下拉列表,我希望它包含列表文档/页面,当选择文档/页面时,该页面应该重定向到所选的文档/页面。



有什么建议可以做到这一点吗?



任何示例/样品将被grealy赞赏?



谢谢:)

解决方案

以下是我问过的问题的解决方案任何人都希望使用它

  public partial class DropDown:System.Web.UI.UserControl 
{
protected void Page_Load(object sender,EventArgs e)
{

FillDropDown(drpList);


}



void FillDropDown(DropDownList drpList)
{

//使用使用来确保资源正确发布
使用(SPSite site = new SPSite(http:// Site /))
{
using(SPWeb web = site.OpenWeb() )
{
SPList oList = web.Lists [ListName];
string url = string.Empty;
foreach(oList.Items中的SPListItem oItem)
{

url = site.MakeFullUrl(oItem.Url);
// drpList.Items.Add(new ListItem(oItem.Name,url));
drpList.Items.Add(new ListItem(oItem.DisplayName,url));

}

}
}
}

void Selection_Change(Object sender,EventArgs e)
{

Response.Redirect(this.drpList.SelectedValue);
}

感谢大家的帮助


I am looking to create a dropdown list on my default.aspx page which i want it to contain List documents/pages and when the document/page is selected the page should redirect to the selected document/page.

Any suggestions of how this can be done please?

any examples/samples would be grealy appreciated?

Thank you :)

解决方案

Below is the solution to the question i had asked if anyone else wishes to use it

public partial class DropDown : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

        FillDropDown(drpList);


    }



    void FillDropDown(DropDownList drpList)
    {

        // Use using to make sure resources are released properly   
        using (SPSite site = new SPSite("http://Site/"))
        {
            using (SPWeb web = site.OpenWeb())
            {
                SPList oList = web.Lists["ListName"];
                string url = string.Empty;
                foreach (SPListItem oItem in oList.Items)
                {

                    url = site.MakeFullUrl(oItem.Url);
                   // drpList.Items.Add(new ListItem(oItem.Name, url));
                    drpList.Items.Add( new ListItem(oItem.DisplayName, url));

                }

            }
        }
    }

   void Selection_Change(Object sender, EventArgs e)
      {

          Response.Redirect(this.drpList.SelectedValue);
      }

Thanks everyone for your help

这篇关于在包含列表文档的Sharepoint中创建一个下拉列表,其中包含指向它们的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆