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,839 times
Add to favorites
E-mail Twitter 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
    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);

        protected override void RenderContents(HtmlTextWriter writer)