SharePoint 2010: Creating Web Parts to Read/Write Data to External Data Sources

Learn how to use Microsoft Visual Studio 2010 to create a Visual Web Part that uses a Microsoft Business Connectivity Services (BCS) external content type in Microsoft SharePoint Server 2010 to read and write data to the AdventureWorks sample database. This sample accompanies the

C# (39.5 KB)
 
 
 
 
 
4 Star
(5)
5,837 times
Add to favorites
8/10/2011
E-mail Twitter del.icio.us Digg Facebook
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace CustomerWebPart.VisualWebPart1
{
    [ToolboxItemAttribute(false)]
    public class VisualWebPart1 : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/CustomerWebPart/VisualWebPart1/VisualWebPart1UserControl.ascx";

        public VisualWebPart1()
        {
        }

        protected override void CreateChildControls()
        {
            Control control = this.Page.LoadControl(_ascxPath);
            Controls.Add(control);
            base.CreateChildControls();
        }

        protected override void RenderContents(HtmlTextWriter writer)
        {
            base.RenderContents(writer);
        }
    }
}