Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I created a WebPart (SharePoint 2013) which contains a ListFieldIterator to display the fields of a list like the New-/EditForm does. According to all online examples and the default new/edit form of a list, the fields should be aligned in a two column table.

fieldname    input
fieldname2   input2
...

But in my case no table is created and all content is displayed one after another

fieldname
input
fieldname2
input2
...

I haven't done anything fancy, just the default values. The ListId is set in the codebehind after the OnInit Event. The ASCX File Snippet:

<SharePoint:ListFieldIterator ID="ListFieldIterator1" runat="server" ControlMode="New"></SharePoint:ListFieldIterator>

What do I have to do to get the two column view (or what have I done wrong, that I did not get it)?

Update: Here is the HTML code created by the Iterator. The two br's are from my code just before the Iterator. Now I see it does create tr and tds but no table tag..?? (this may be the reason why the IE Developer Tool stripped them all out and I thought there are no row and cell tags). So my (new) question: Why is there no Table tag?

<br /><br />


    <tr>
    <td nowrap="true" valign="top" width="113px" class="ms-formlabel"><h3 class="ms-standardheader">
    <nobr>Headline<span class="ms-accentText" title="This is a required field." > *</span></nobr>
</h3></td>
    <td valign="top" width="350px" class="ms-formbody">
    <!-- FieldName="Headline"
         FieldInternalName="Title"
         FieldType="SPFieldText"
      -->
        <span dir="none">
    <input name="ctl00$[...]$ctl00$TextField" type="text" maxlength="200" id="ctl00_[...]_TextField" title="Headline" class="ms-long ms-spellcheck-true" /><br />
</span>


    </td>
</tr>
... more fields ... 

Update: This is the code I use now. I guess it is really intended that the ListFieldIterator does not create table tags in case you want to add custom fields to the same table. Until someone has a better Explanation?

<table class="ms-formtable">
    <SharePoint:ListFieldIterator ID="ListFieldIterator1" runat="server" ControlMode="New"></SharePoint:ListFieldIterator>
</table>
share|improve this question
    
Could you please provide html markup that was rendered for field controls? –  Andrew May 22 '13 at 15:40
    
Updated the post. Seems like the ListFieldIterator does not create the <table> Tag. I will try adding it manually but this is a big hack and can't be the solution. –  Kirschi May 23 '13 at 13:21
add comment

2 Answers

up vote 0 down vote accepted

Because I did not find any other Solutions to this problem, I guess that adding your own table tag is the only solution to this Feature. Maybe so you can concatenate serveral ListFieldIterators to one large table.

<table class="ms-formtable">
  <SharePoint:ListFieldIterator ID="ListFieldIterator1" runat="server" ControlMode="New"></SharePoint:ListFieldIterator>
</table>
share|improve this answer
add comment

Besides surrounding the iterator with a table you must instruct the iterator control to apply a specific rendering template: PropertyIterator (in my case). When using this template it will generate the field controls and labels inside table cells, using a row per field

<table class="ms-formtable" border="0" cellpadding="2">
<SharePoint:ListFieldIterator runat="server" ID="**FormIterator**" TemplateName="PropertyIterator" />
</table>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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