1

I'm trying go make a custom list form when editing a list item, which should show some associated items from another list. I already fail at making a custom form for editing. I made a new RenderingTemplate and it already shows up when I edit a list item. At the moment im adding a new gridview with id GridView1:

    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register TagPrefix="wssuc" TagName="ToolBar" Src="~/_controltemplates/ToolBar.ascx" %>
<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="OrderControl.ascx.cs" Inherits="Shop.CONTROLTEMPLATES.OrderControl" %>
<%@ Register TagPrefix="Shop" TagName="OrderItemsControl" Src="OrderItemsControl.ascx" %>
<SharePoint:RenderingTemplate ID="OrderControlTemplate" runat="server">
    <Template>
        <table>
            <tr>
                <td>
                    <span id='part1'>
                        <SharePoint:InformationBar ID="InformationBar1" runat="server" />
                        <div id="listFormToolBarTop">
                            <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbltop" RightButtonSeparator="&amp;#160;" runat="server">
                                <template_rightbuttons>
                                    <SharePoint:NextPageButton runat="server"/>
                                    <SharePoint:SaveButton runat="server"/>
                                    <SharePoint:GoBackButton runat="server"/>
                                </template_rightbuttons>
                            </wssuc:ToolBar>
                        </div>
                        <SharePoint:FormToolBar ID="FormToolBar1" runat="server" />
                        <SharePoint:ItemValidationFailedMessage ID="ItemValidationFailedMessage1" runat="server" />
                        <table class="ms-formtable" style="margin-top: 8px;" border="0" cellpadding="0" cellspacing="0" width="100%">
                            <SharePoint:ChangeContentType ID="ChangeContentType1" runat="server" />
                            <SharePoint:FolderFormFields ID="FolderFormFields1" runat="server" />
                            <SharePoint:ListFieldIterator ID="ListFieldIterator1" runat="server" />

                            <SharePoint:ApprovalStatus ID="ApprovalStatus1" runat="server" />
                            <SharePoint:FormComponent ID="FormComponent1" TemplateName="AttachmentRows" ComponentRequiresPostback="false" runat="server" />
                        </table>
                        <table cellpadding="0" cellspacing="0" width="100%" style="padding-top: 7px">
                            <tr>
                                <td width="100%">
                                    <asp:Label ID="lbl1" runat="server">OrderItems</asp:Label><asp:Button ID="Button1" OnClick="Button1_Click" runat="server" Text="Testbtn" />
                                    <asp:GridView ID="GridView1" runat="server"></asp:GridView>

                                    <SharePoint:ItemHiddenVersion ID="ItemHiddenVersion1" runat="server" />
                                    <SharePoint:ParentInformationField ID="ParentInformationField1" runat="server" />
                                    <SharePoint:InitContentType ID="InitContentType1" runat="server" />
                                    <wssuc:ToolBar CssClass="ms-formtoolbar" id="toolBarTbl" RightButtonSeparator="&amp;#160;" runat="server">
                                        <template_buttons>
                                    <SharePoint:CreatedModifiedInfo runat="server"/>
                                </template_buttons>
                                        <template_rightbuttons>
                                    <SharePoint:SaveButton runat="server"/>
                                    <SharePoint:GoBackButton runat="server"/>
                                </template_rightbuttons>
                                    </wssuc:ToolBar>
                                </td>
                            </tr>
                        </table>
                    </span>
                </td>
                <td valign="top">
                    <SharePoint:DelegateControl ID="DelegateControl1" runat="server" ControlId="RelatedItemsPlaceHolder" />
                </td>
            </tr>
        </table>
        <SharePoint:AttachmentUpload ID="AttachmentUpload1" runat="server" />
    </Template>
</SharePoint:RenderingTemplate>

when I'm entering the Edit-Mode for a Listitem, I get an empty page. Why is that?

I also tried to edit the GridView from the code behind but I wasn't able to get it there when searching by ID.

How can I use the grid view in a custom Edit-Item-Form?

2
  • use jquery SPServices library SPDisplayRelatedInfo spservices.codeplex.com/… Apr 17 '14 at 9:59
  • I found out that if you want to refer to another List, it is best to make a new User Control for this List and then using the Reference Tag: <%@ Register TagPrefix="Custom" TagName="OrderItemsControl" Src="OrderItemsControl.ascx" %> And on the Position where you want to have this content, use: <Custom:OrderItemsControl runat="server" /> This lets you view items from another list in the edit-view of another lists list-item-edit-view. I needed it to display the items of a order when editing/viewing the order-item.
    – Gwny
    Apr 17 '14 at 15:03
1

I found out that if you want to refer to another List, it is best to make a new User Control for this List and then using the Reference Tag:
<%@ Register TagPrefix="Custom" TagName="OrderItemsControl" Src="OrderItemsControl.ascx" %>

And on the Position where you want to have this content, use:
<Custom:OrderItemsControl runat="server" />

This lets you view items from another list in the edit-view of another lists list-item-edit-view. I needed it to display the items of a order when editing/viewing the order-item.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.