I have created a custom list form and inside of it I am using a Repeater Control. But If inside of Repeater I create a <SharePoint:FormField runat="server" ControlMode="New" FieldName="Title" /> the control is not being shown All I see is this: enter image description here

Which means that the input field is missing. Here is the repeater code in aspx

<asp:Repeater runat="server" ID="rptrMain">                                               
             <td width="190px" valign="top" class="ms-formlabel">
                 <h3 class="ms-standardheader">
                     <nobr> Title<span  class="ms-formvalidation">  *</span></nobr>
             <td width="400px" valign="top" class="ms-formbody">
                 <SharePoint:FormField runat="server" ControlMode="New" FieldName="Title" />
                 <SharePoint:FormField runat="server" ControlMode="New" FieldName="FirstName" />
                 <SharePoint:FieldDescription runat="server" FieldName="Title" ControlMode="New" />

However now If I remove the Repeater control I have the following result: enter image description here

my C# code:

            using (SPSite site = new SPSite(SPContext.Current.Site.Url))
                using (SPWeb web = site.OpenWeb())
                    SPList list = web.GetList("http://mysite/sites/mysite/Lists/EmployeeCardSections");
                    if (list != null)
                        SPQuery query = new SPQuery();
                        SPListItemCollection collitem = list.GetItems();
                        rptrMain.DataSource = collitem.GetDataTable();

so how to fix this problem please help me!

  • what does your C# code looks like? – Akshay Randive Dec 16 '17 at 8:35
  • @AkshayRandive Check the updated question – Nderon Hyseni Dec 16 '17 at 8:54
  • What do you want to achieve with the repeater? – Damjan Tomic Dec 16 '17 at 16:20
  • I want to dynamically show form Field – Nderon Hyseni Dec 16 '17 at 18:00

I suggest that use html tag instead of SharePoint server-side control. You can retrieve form field via CSOM or SSOM.

Here is a simple demo for your reference:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyApplicationPage2.aspx.cs" Inherits="SharePointFarmSolutionDev.Layouts.SharePointFarmSolutionDev.MyApplicationPage2" DynamicMasterPageFile="~masterurl/default.master" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">


<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

<div id="dvCustomers">
<asp:Repeater ID="rptCustomers" runat="server">
            <table class="tblCustomer" cellpadding="2" cellspacing="0" border="1">
                    <b><u><span class="name">
                        <%# Eval("ContactName") %></span></u></b>
                    <b>City: </b><span class="city"><%# Eval("City") %></span><br />
                    <b>Postal Code: </b><span class="postal"><%# Eval("PostalCode") %></span><br />
                    <b>Country: </b><span class="country"><%# Eval("Country")%></span><br />
                    <b>Phone: </b><span class="phone"><%# Eval("Phone")%></span><br />
                    <b>Fax: </b><span class="fax"><%# Eval("Fax")%></span><br />

<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
Application Page

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
My Application Page

C# Code as below:

using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Web.Services;
using System.Collections.Generic;
using Microsoft.SharePoint.Client;

namespace SharePointFarmSolutionDev.Layouts.SharePointFarmSolutionDev
  public partial class MyApplicationPage2 : LayoutsPageBase
    protected void Page_Load(object sender, EventArgs e)
        string siteURL = "your site url";
        ClientContext context = new ClientContext(siteURL);
        List list = context.Web.Lists.GetByTitle("MyCustomList");


        ListItem item = list.GetItemById(1);

        Customer customer = new Customer();
        customer.City = item["City"].ToString();
        customer.CustomerId = item["CustomerId"].ToString();
        customer.ContactName = item["ContactName"].ToString();
        customer.Country = item["Country"].ToString();
        customer.PostalCode = item["PostalCode"].ToString();
        customer.Phone = item["Phone"].ToString();
        customer.Fax = item["Fax"].ToString();

        List<Customer> customers = new List<Customer>();

        rptCustomers.DataSource = customers;
  • but this does not retrieve the list form it only retrieves the data, instead I want to retrieve the inputs form – Nderon Hyseni Jan 4 '18 at 10:14
  • I do not want to have a displaay form, but a custom NewForm – Nderon Hyseni Jan 4 '18 at 12:51

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.