Through this blog, it is my effort to share experiences with the community and make the journey enjoyable.

Tuesday, September 30, 2008

Custom DataSheet View Using ListNet ActiveX Control

Introduction -

SharePoint DataSheet Page is used for editing lists in multiple record grid format. DataSheet view uses ListNet control, which is an ActiveX control. This control is also works in conjunction with the ListViewWebPart class to provide users with a dataview for editing lists in Microsoft Windows SharePoint Services.

ListNet control is defined in the STSLIST.DLL file, a dynamic-link library (DLL) that is installed on the client during 2007 Office system setup in the Local_Drive:\Program Files\Microsoft Office\OFFICE12 directory.

Analyzing out-of-box 'Edit in DataGrid' Page -

On clicking on 'Edit in DataGrid', redirection to 'AllItems.aspx' (~site/{DocLib}Forms/AllItems.aspx?ShowInGrid=True&View={ViewGuid}) happens.

In summary, looking at the source of the page, it contains Script tag, which calls Javascript function, RenderActiveX. RenderActiveX has the object tag with class id={65BCBEE4-7728-41a0-97BE-14E1CAE36AAE}.

Parameters which are set on the page, to render the ActiveX are - ListName, ViewGuid, ListWeb. ListData, ViewSchema, ListSchema.

In summary, below is the script tag -
<SCRIPT>RenderActiveX("<OBJECT id='STSListControlWPQ2' name='STSListControlWPQ2' classid=CLSID:65BCBEE4-7728-41a0-97BE-14E1CAE36AAE PARAM NAME='ListName' VALUE='{ListID} PARAM NAME=ViewGuid VALUE={ViewID} PARAM NAME=ListWeb VALUE={WebUrl} PARAM NAME='ListData' VALUE={ListData} PARAM NAME=ViewSchema VALUE={ViewSchema} PARAM NAME='ListSchema' VALUE={ListSchema} PARAM NAME='ControlName' VALUE='STSListControlWPQ2' > </OBJECT>");</SCRIPT>

Custom Application Page using ListNet ActiveX Page -
Below is some of the code snippet used in the application page. Application Page is passed two query parameters ListId and WebId, to create dynamic view for the list in the web.

<script runat="server">
SPWeb web;
SPList list;
string ListData, ViewSchema, ListSchema;

protected override void OnLoad(EventArgs e)
//Reading ListId querstring parameter
Guid listGuid = new Guid(Request.QueryString.Get("ListId"));

//Reading WebId querstring paramter
Guid webGuid = new Guid(Request.QueryString.Get("WebId"));

SPSite site = SPContext.Current.Site;
web = site.OpenWeb(webGuid);
list = web.Lists[listGuid];

//Custom string functions, STSHtmlEncode & STSScriptEncode to encode the string
ListData = STSScriptEncode(STSHtmlEncode(list.Items.Xml));
ViewSchema = STSScriptEncode(STSHtmlEncode(list.DefaultView.SchemaXml));
ListSchema = STSScriptEncode(STSHtmlEncode(list.SchemaXml));


<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<SCRIPT>RenderActiveX("\u003cOBJECT id=\u0022STSListControlWPQ2\u0022 name=\u0022STSListControlWPQ2\u0022 classid=CLSID:65BCBEE4-7728-41a0-97BE-14E1CAE36AAE width=\u002299\u0025\u0022 tabindex=\u00221\u0022\u003e\u003cPARAM NAME=\u0022ListName\u0022 VALUE=\u0022{<%=list.ID.ToString()%>}\u0022\u003e\u003cPARAM NAME=\u0022ViewGuid\u0022 VALUE=\u0022{<%=list.DefaultView.ID.ToString()%>}\u0022\u003e\u003cPARAM NAME=\u0022ListWeb\u0022 VALUE=\u0022<%=web.Url%>\u002f_vti_bin\u0022\u003e\u003cPARAM NAME=\u0022ListData\u0022 VALUE=\u0022<%=ListData%>\u0022\u003e\u003cPARAM NAME=\u0022ViewSchema\u0022 VALUE=\u0022<%=ViewSchema%>\u0022\u003e\u003cPARAM NAME=\u0022ListSchema\u0022 VALUE=\u0022<%=ListSchema%>\u0022\u003e\u003cPARAM NAME=\u0022ControlName\u0022 VALUE=\u0022STSListControlWPQ2\u0022\u003e\u003cp class=ms-descriptiontext\u003eThe Datasheet view of this list cannot be displayed. Please wait while the page is redirected to Standard view. If your list does not appear in a few moments, \u003cA onclick=\u0022javascript:GCNavigateToNonGridPage\u0028\u0029; javascript:return false;\u0022 href=\u0022?ShowInGrid=False\u0022 target=_self\u003eopen the list in Standard view\u003c\u002fA\u003e\u003c\u002fp\u003e\u003c\u002fOBJECT\u003e");




  1. Hello!

    How can I pass the server variables (e.g. ListData, ListSchema) to the client function RenderActiveX?

  2. Many institutions limit access to their online information. Making this information available will be an asset to all.

  3. Can you explain in detail how to make custom control ?

  4. This looks very close to what I am looking for, however I get following error:

    "The name 'STSScriptEncode' does not exist in the current context"

    Am I missing something? Any help will be appreciated.

    Thanks in advance :-)


Search This Blog


The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway. All posts are provided "AS IS" with no warranties, and confers no rights. In addition, my thoughts and opinions often change, and as a weblog is intended to provide a semi-permanent point in time snapshot you should not consider out of date posts to reflect my current thoughts and opinions.

Popular Posts

Total Pageviews