刷新列表Web部件以反映在使用visual studio 2010开发的sharepoint 2010中添加的项目



我有一个列出学生的可视化Web部件。

还有一个可添加/编辑学生的Web部件。

部署应用程序后,我创建了新的Web部件页面,并在一个区域中添加了CreateStudent Web部件,在另一个区域添加了ListStudent Web部分。

当我添加一个学生时,我需要在ListStudent Web部件的网格中找到该学生的详细信息。

我认为我需要连接两个Web部件,使CreateStudent Web部件作为提供者Web部件,ListStudent Web部分作为消费者Web部件,但我的疑问是,我不需要向ListStudent网络部件传递任何特定的值。

我在ListStudent Web部件Page_Load中有一个函数调用,它设置了网格视图的数据源并将其绑定。如何做到这一点?

以下是满足您需求的链接,

我想这对你会有帮助的。

http://www.dotnetcurry.com/ShowArticle.aspx?ID=678

问候。

这是另一个完全满足您需求的链接,

http://blogs.msdn.com/b/pranab/archive/2008/07/02/step-by-step-creating-connected-sharepoint-web-parts-using-iwebpartfield-interface-and-using-editor-part-and-user-controls.aspx

以下是简单的提供者和使用者Web部件。提供者UI接受一个文本字段,并将其传递给使用者Web部件,使用者Web部件只是输出它

namespace ConnectedWebParts
{
    public interface IParcel
    {
        string ID { get; }
    }
}

提供者Web部件实现了这个接口,并且必须有一个返回自身的属性ConnectionProvider的方法(因为它实现了接口):

namespace ConnectedWebParts
{
    public class ProviderWebPart : WebPart, IParcel
    {
        protected TextBox txtParcelID;
        protected Button btnSubmit;
        private string _parcelID = "";
        protected override void CreateChildControls()
        {
            txtParcelID = new TextBox() { ID = "txtParcelID" };
            btnSubmit = new Button() { ID = "btnSubmit", Text="Submit"};
            btnSubmit.Click += btnSubmit_Click;
            this.Controls.Add(txtParcelID);
            this.Controls.Add(btnSubmit);
        }
        void btnSubmit_Click(object sender, EventArgs e)
        {
            _parcelID = txtParcelID.Text;
        }
        [ConnectionProvider("Parcel ID")]
        public IParcel GetParcelProvider()
        {
             return this;
        }
        string IParcel.ID
        {
             get { this.EnsureChildControls();  return _parcelID; }
        }
     }
 }

使用者Web部件必须定义一个具有ConnectionConsumer属性的方法,该方法接受实现连接接口(提供者Web部件)的对象作为参数:

namespace ConnectedWebParts
{
    public class ConsumerWebPart : WebPart
    {
        protected IParcel _provider;
        protected Label lblParcelID;
        protected override void CreateChildControls()
        {
            lblParcelID = new Label();
            if (_provider != null && !String.IsNullOrEmpty(_provider.ID))
                lblParcelID.Text = _provider.ID;    
            this.Controls.Add(lblParcelID);
        }
        [ConnectionConsumer("Parcel ID")]
        public void RegisterParcelProvider(IParcel provider)
        {
            _provider = provider;
        }
    }
}

最新更新