Data lost with new item DataFormWebPart


  • After I submit a custom new item DataFormWebPart<//span> with asp:TextBox controls data may be lost if form does not validate once. When submitting the form the second time the fields are filled with text but they don’t make it to the Sharepoint list.

    Here is the setup:

    • Blank ASPX page created in Sharepoint
    • Created a new List item DataFormWebPart
    • One input fields require values
    • Some fields are formatted as ASP TextBox Items

    When I use the form and fill out all the fields and submit. All the data gets into the Sharepoint List Item as expected. If I fill everything out except the required field and submit the form, the page refresh and some red text appears letting you know you need the field filled out as it should. The second page has all the fields still fill out. I fill in the required field I left blank before and click submit again. The Sharepoint list t

    hen shows and there is a new item, but the asp:Textbox field columns are blank and the data was lost. If I edit them one the second time the data seems to be kept.

    I suspect it has something to do with the fact that fields are not SharePoint:FormField but rather asp:TextBox.  Can anyone else confirm this issue or is some of my code just wrong? Is there a workaround?


    Would it be possible to override the submit button and do my on validation? And hope there are no post backs of the forum.  Maybe some Javascript on the page that just adds and removes a space from all fields.

    Here is  the control code:

    <asp:TextBox Width="525px" runat="server" id="ff1{$Pos}" text="{@Title}"

    __designer:bind="{ddwrt:DataBind('i',concat('ff1',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Title')}" />

    I just tested it with a page from scratch and it has the issue as well. Also, any attachments are lost as well.

    • 已编辑 gsan2k 2012年2月28日 23:36
    2012年2月28日 23:04



    Hi gsan2k,

    This behavior is by design in Microsoft Windows SharePoint Services 3.0 and in Microsoft Office SharePoint Server 2007. At least one SharePoint FormField control must be present in the Web Part, if not, it will overwrite the first item in the list.

    Here is a KB article to description of it.

    if you want to validate your custom field, please refer to the following KB link.



    2012年3月1日 2:44

    Thanks for the response; that is almost exactly the issue I am having but not quite.

    My form has 6 SharePoint:FormField’s and 3 asp:TextBox’s.  One of the SharePoint:FormField’s has a required value constraint that comes from the list item columns settings on Sharepoint. If you fill out the form and leave the one with the required value blank, you get the Sharepoint “value required” message after submitting it. If this occurs, all attachments are lost and the values in the asp fields appear in the second time on the form but the data never makes it into Sharepoint after successfully submitting the form. The 6 SharePoint:FormField’s make it into Sharepoint fine.

    • 已编辑 gsan2k 2012年3月1日 17:28
    2012年3月1日 17:26
  • Hi gansk,

    I was having the same issue as you were and came across the following post:

    In it, they used the EnableViewState=False for each of their ASP.NET fields to get around the issue of the fields being blank after submitting it.  I had the same issue and did this as well and it worked for me.  I can't explain why it works, but it does.  Hope this helps you.

    2012年4月2日 14:24