none
Mostrar una Sharepoint List en Vista Datasheet RRS feed

  • Pregunta

  • Hola a todos, estoy desarrollando una pagina aspx, la cual contiene un ListViewWebPart para mostrar una lista de sharepoint personalizada, esta lista por default se muestra en datasheet view (basada en un template list), pero cuando la muestro en el webpart de mi pagina, esta se muestra en la vista standard siempre. Alguien sabe como forzar al ListViewWebPart para mostrar la vista del datasheet?

    Este es mi Codigo C#

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImportationData.aspx.cs" <br/>
    Inherits="ISPackageTrigger.ImportationData, ISPackageTrigger, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f5ec6d4a48b80b4b" %><br/>
    <%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages"<br/>
      Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %><br/>
    <%@ Register Assembly="Telerik.Web.UI, Version=2010.1.309.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4"<br/>
      NameSpace="Telerik.Web.UI" TagPrefix="Telerik"%><br/>
    <asp:Content contentplaceholderid="PlaceHolderPageTitle" runat="server"><br/>
      Data Importation<br/>
    </asp:Content><br/>
    <asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server"><br/>
    </asp:Content><br/>
    <asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server"><br/>
    <asp:Panel runat="server" ID="toolboxPanel"></asp:Panel><br/>
      <WebPartPages:ListViewWebPart ID="oListViewWP" runat="server" __WebPartId="{2D208CBC-764D-4fb3-9CC2-EDA977415B2F}"><br/>
      </WebPartPages:ListViewWebPart><br/>
    </asp:Content>
    

     

    using System;<br/>
    using System.Collections.Generic;<br/>
    using System.Linq;<br/>
    using System.Web;<br/>
    using System.Web.UI;<br/>
    using System.Web.UI.WebControls;<br/>
    using Microsoft.SharePoint;<br/>
    using Microsoft.SharePoint.WebControls;<br/>
    using Nuvek.SPDataAccess;<br/>
    using System.Data;<br/>
    <br/>
    namespace ISPackageTrigger<br/>
    {<br/>
      public partial class ImportationData : System.Web.UI.Page<br/>
      {<br/>
        protected SPWeb _teamSite;<br/>
        protected override void OnPreInit(EventArgs e)<br/>
        {<br/>
          base.OnPreInit(e);<br/>
          _teamSite = SPControl.GetContextWeb(Context);<br/>
          this.MasterPageFile = _teamSite.MasterUrl;<br/>
        }<br/>
        protected override void OnLoad(EventArgs e)<br/>
        {<br/>
          base.OnLoad(e);<br/>
          string includeTemplate = @"<link rel=""stylesheet"" type=""text/css"" href=""{0}"" />";<br/>
          LiteralControl cssControl = new LiteralControl(string.Format(includeTemplate,<br/>
            "/_wpresources/ISPackageTrigger/1.0.0.0__f5ec6d4a48b80b4b/css/ImportationData.css"));<br/>
          Page.Header.Controls.Add(cssControl);<br/>
        }<br/>
        protected void Page_Load(object sender, EventArgs e)<br/>
        {<br/>
          SPList oList = CreateList();<br/>
          if (oList != null)<br/>
          {<br/>
            oListViewWP.ListName = oList.ID.ToString("B").ToUpper();<br/>
            oListViewWP.ViewGuid = oList.Views[0].ID.ToString("B").ToUpper();<br/>
            oListViewWP.SuppressWebPartChrome = true;<br/>
            oListViewWP.GetDesignTimeHtml();<br/>
            ViewToolBar toolBar = new ViewToolBar();<br/>
            toolBar.ID = "toolBar";<br/>
            toolBar.RenderContext = SPContext.GetContext(Context, oList.Views[0].ID, oList.ID,<br/>
              SPContext.Current.Web);<br/>
            toolboxPanel.Controls.Add(toolBar);<br/>
          }<br/>
        }<br/>
        protected SPList CreateList()<br/>
        {<br/>
          SPList oList = null;<br/>
          string userName = HttpContext.Current.User.Identity.Name;<br/>
          string[] tokens = userName.Split(new char[] { '\\' });<br/>
          string listName = string.Format("Snow_Invoice_{0}", tokens[1]);<br/>
          var lists = from l in _teamSite.Lists.Cast<SPList>()<br/>
                where l.Title == listName<br/>
                select l;<br/>
          if (lists.Count() == 0)<br/>
          {<br/>
            SPSite siteCollection = SPContext.Current.Site;<br/>
            SPListTemplateCollection listTemplates = siteCollection.GetCustomListTemplates(_teamSite);<br/>
            SPListTemplate template = listTemplates["Snow_Invoice_Import_Template"];<br/>
            if (template != null)<br/>
            {<br/>
              _teamSite.AllowUnsafeUpdates = true;<br/>
              _teamSite.Lists.Add(listName, string.Empty, template);<br/>
              _teamSite.Update();<br/>
              oList = _teamSite.Lists[listName];<br/>
            }<br/>
          }<br/>
          else<br/>
          {<br/>
            oList = lists.First<SPList>();<br/>
          }<br/>
          return oList;<br/>
        }<br/>
      }<br/>
    }
    

    De antemano muchas gracias.

    viernes, 3 de septiembre de 2010 0:36