Developing Visual Web Part with external list in ListView

Mick
  • Developing Visual Web Part with external list in ListView Mick

    Using VS 2010 i've created BCS model for external MS SQL source, deployed it with success, then created external list - it works perfect.

    Now my task is - create visual web part in VS2010 and place sharepoint:ListView in it to display external list. See code for CreateChildControls() method:

        protected override void CreateChildControls()
        {
           // Control control = Page.LoadControl(_ascxPath);
           // Controls.Add(control);
    
            Microsoft.SharePoint.WebControls.ListView view = new Microsoft.SharePoint.WebControls.ListView();
            SPList list = SPContext.Current.Web.Lists["Doc"];
            view.ListId = list.ID.ToString();
            view.ViewId = list.Views["ReadListByCategory"].ID.ToString();
    
            Controls.Add(view);
        }
    

    After adding web part on page i got error:

    !--Unable to display web part--.

    There is no problem with other sharepoint lists. Only with external list.

    Does anyone have experience in creating Web Part with External list in it?

Tags
web-part bcs list
Related questions and answers
  • I've created a Custom List ('Tooltips') in SharePoint. After this I used SPSource to reverse engineer the list into a feature. After installing and activating this feature, I want to add this list in a WebPart zone. When doing this, I get an error message : Tooltips: List View Web Part could not be added, list may be hidden. What's wrong with the list? feature.xml <?xml version="1.0" encoding="utf-8"?> <Feature Id="70d49f3d-233a-482d-97e3-dcec2c236171" Title="MyApp - Tooltips" Description="Creates a Tooltips list which can be used for mouse-over texts

  • I have created a "Hello World" web part. When I pressed F5 in Visual Studio 2010, I got the following error. I have already got Microsoft SharePoint Foundation User Code Service started. Can anyone... Application Registry Service 46e7ddc8-49af-4a7e-9eee-155f526ed509 Microsoft SharePoint Foundation User Code Service... b5b08230-d2ae-4689-b396-bb217462a20e Microsoft SharePoint Foundation Web Application

  • I have come across blogs about how to setup an external content type. For example: http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/02/02/it-s-easy-to-configure-an-external-list-with-business-connectivity-services-bcs-in-sharepoint-foundation-2010.aspx But I have not seen any examples of what to do when your external SQL DB has foreign keys. For example. I have a database that has orders and customers. An order has one and only one customer and a customer can have many orders. How can I setup external content types in such a way that when in the list view of these external

  • the Supporting Files tab on the List Properties dialogue box for List B. However, when I try to display the data in List B, I get the following error: “Unable to display this Web Part....” I’m guessing this has something to do with customized DispForm having some code in it that prevents it from pulling in data from List B. I’m using WSS 3.0 and SharePoint Designer 2007. Any help...I have two lists (List A and List B) that were created from the same list template. The Dispform for List A was customized (some fields were cut out and others were rearranged). The customized

  • I want to show the contents of three specific columns from one specific list item. Like Meeting list item ID 5 contains Name MeetingDate Bitfield1 Bitfield2 John Doe 23-06-2010 Yes No In a web part (if possible) I want to create this view: Meeting Date: 23-06-2010 Bitfield1: Yes Bitfield2: No (Edit link to Meeting list item ID 5) Is that possible without coding a web part from scratch? E.g. with the XML web part or others? (solution is MOSS 2007 Enterprise based if that's relevant)

  • I am using SharePoint 2007 + Windows Server 2008 with SharePoint 2007's publishing portal template. I have created a list with datasheet view on a page (I add the list by adding a Web Part -> then select the list control to add it as a web part to the page.) When create the list, I have added 5 columns, and inserted some rows. My question is, how to remove one column of the list?

  • How can I get the selected language in the screenshot, from inside of a webpart? alt text http://thomasstock.net/currentlanguage.png I'm using SharePoint 2010. My webpart is a "visual web part" created in VS2010. I'm trying things like SPContext.Current.Web.CurrentUser.RegionalSettings and SPContext.Current.Web.Language" but ofcourse these things have nothing to do with that setting. :-| Can someone please help me? What property am I looking for.

  • I was working on a project to provide Up Button functionality for the list view web part, and ran across this functionality in the Reusable Content popup. I opened reflector and set to work to reverse the engineer the code for use on any list view. While doing so I created an error on the Reusable Content page (I believe it is called ReusableContentPicker.aspx but I am away from my VM and can't check.) and deleted the list view web part that was displaying the Reusable Content list from the page in web part maintenance mode. Not enough coffee that morning (>_<) Now when I load the page

  • ) { SPList list = web.Lists["Web Part Gallery"]; // go through the items in reverse //for (int i = list.ItemCount – 1; i >= 0; i–) for(int i=list.ItemCount-1; i >=0...I have a webpart i build using WSpBuilder and it works OK. When i use Deploy from Visual Studio it installs the WSP sharepoint and add the webpart to the webpart gallery. But it seems the feature does activate the webpart but i also want to remove it when deactivating it.(So i know i need to add something to the FeatureDeactivating So i created a Feature With Reciever template and added

Data information