次の方法で共有


SharePoint 2007 (MOSS/WSS) Custom BDC Web Part Example

Here is an example of a simple Custom Business Data Catalog (BDC) Web Part. I have used a BDC Metadata file which connects to Northwind database. It has reference of both Categories and Products table. But in this example I have only listed all Category ID and Category Name from Categories table. Here is the link to download the Metadata file.

In the Web Part Project add reference of microsoft.sharepoint.portal namespace. You can find the dll in this location - "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\microsoft.sharepoint.portal.dll". Here is the code for the Web Part:

using System;

using System.Runtime.InteropServices;

using System.Web.UI;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Serialization;

using Microsoft.SharePoint;

using Microsoft.SharePoint.WebControls;

using Microsoft.SharePoint.WebPartPages;

using Microsoft.Office.Server.ApplicationRegistry.Runtime;

using Microsoft.Office.Server.ApplicationRegistry.Infrastructure;

using Microsoft.Office.Server.ApplicationRegistry.MetadataModel;

namespace CustomBDCWP

{

[Guid("b42363a0-ef07-4247-81c3-cf567e617248")]

public class CustomBDCWP : System.Web.UI.WebControls.WebParts.WebPart

{

protected override void Render(HtmlTextWriter writer)

{

LobSystem nwSystem = ApplicationRegistry.GetLobSystems()["NorthwindLOBSystem"];

LobSystemInstance nwSystemInstance = nwSystem.GetLobSystemInstances()["NorthwindInstance"];

Entity categoryEntity = nwSystem.GetEntities()["dbo.Categories"];

FilterCollection fc = categoryEntity.GetFinderFilters();

IEntityInstanceEnumerator nwInstanceEnumerator = categoryEntity.FindFiltered(fc, nwSystemInstance);

writer.Write("<Table>");

while (nwInstanceEnumerator.MoveNext())

{

IEntityInstance category = nwInstanceEnumerator.Current;

writer.Write("<tr><td>" + category["CategoryID"].ToString() + "</td><td>" + category["CategoryName"].ToString() + "</td></tr>");

}

writer.Write("</Table>");

}

}

}

nw.xml

Comments

  • Anonymous
    November 06, 2007
    PingBack from http://stevepietrekweblog.wordpress.com/2007/11/06/links-1162007/

  • Anonymous
    December 18, 2007
    Is it possible to incorporate Sharepoint workflow into a BDC webpart?

  • Anonymous
    May 23, 2008
    HI Pranab , This blog is very good ,The example which you have showed can it  have all the properties like BDI or BDL i.e Xml editor ,caching etc Thanks

  • Anonymous
    May 23, 2008
    HI Pranab, i need to made the new webpart such that it will extend the Business data Item (BDI) but i did not find the base class for BDI , to which i will extend to my webpart something like class a :BDIClass { } from where i will g et BDIClass I need to do this so that i can make the web part same as BDI with  some extra feature but needs all the property of BDI like xml editor ,caching etc is their any other approach or i am in wrong track Can you show me the light ?? Thanks, Neeraj

  • Anonymous
    May 23, 2008
    HI , i need to made the new webpart such that it will extend the Business data Item (BDI) but i did not find the base class for BDI , to which i will extend to my webpart something like class a :BDIClass { } from where i will g et BDIClass I need to do this so that i can make the web part same as BDI with  some extra feature but needs all the property of BDI like xml editor ,caching etc is their any other approach or i am in wrong track Thanks, Neeraj

  • Anonymous
    January 19, 2009
    Hi !! I have idea to develop web part of room plan. This is the requirement. User should enter location and item detail of room. Those data should be store in xml file. Then room plan graphic is automatically created. Can any one know how to draw plan (image) using web part..?? Please give me some idea to start this web part . thanX. regards, nalaka

  • Anonymous
    August 25, 2009
    If you need workflow (if external business data is changed) you can use the SharePoint Business Data List Connector. The BDLC connects a real SharePoint list directly with almost any external LOB data using common list settings with 3 easy steps:

  1. Enter connection string
  2. Enter select statement
  3. Enter primary keys Fast background updates of changed data only: Alerts and workflows can be used, to take business actions, if external data records are changed. The feature comes with a robust installer and is available for WSS, MOSS and SharePoint 2010 with release.