Recently for a contact list form I used the DataFormWebPart.

First I created a custom list then added the Data Form Web Part to a page. Exported the code included the web part code in my project.

In the SharePoint logs I got something like this:

An unexpected error has been encountered in this Web Part.  Error: Cannot import this Web Part

Ai, it’s that same old problem where SharePoint Designer uses the ListId instead of the ListName. So I sorted this out my replacing all (in total 5)the ListId with ListName and … Next error. I was sure that this worked before so what happened?

I tried it all again but this time I changed the ListId to ListName one by one and I found that the following occurence caused the problem.

<WebPartPages:DataFormWebPart runat=”server” Title=”Contact Us” ListId=”{8BB37EDA-4D6E-45AF-87E0-550842A88292}” …

Changing ListId to ListName simply doesn’t do the trick here. A New attribute ListDisplayName did work. The end result:

<WebPartPages:DataFormWebPart runat=”server” Title=”Contact Us” ListDisplayName=”Contact Us” …

Why ListName, ListDisplayName are mixed up is a big question. But as long as it works…

Advertisements