XSLT Data View Web Parts in SharePoint Designer- Why changing the layout is can break your template.

My last post offered clues as to why Data View web parts break. All my previous web parts were using custom Layouts to strip out all the surrounding layout tables.

Here is a rough idea how the default Layout is constructed.

Figure 1- The above is a default Multi-item XSLT Data View web part template without paging (Display all items). Notice how there is a Table Row (TR) for each data row.

Normally, in the past, I did not want my data to be separated in its own table row (TR). I wanted my data to be separated with a line break, or all on the same line, or all in the same row. I would change the layout.

The problem with this is, after multiple re-saving of the ASPX page in SharePoint Designer, the page begins to auto insert generated code into the page or DataView web part. This causes the web part to break and you can lose your template.

The workaround:

Instead of changing your layout, try to work with the existing layout. That’s it!

Here is a diagram of what I wanted:

Figure 2- Basically, it’s the same template as above. I removed the TH text, but left the code. For the Green TD above, I used XSL:Text disable-output-escaping=yes to construct all my conditions.

The above is just my example, as there is a lot of formatting. Basically I have Id’s, Classes, and Numbers I sort by and place in their own TD’s, TR’s (Every 5 cells), and headers for every certain number. Each class has its own TD. (specific to my data schema)

The point I am trying to prove is that outside of the For-Each is intact. All my modifications were around this for-each, but not to my TH class, or any other template.


3 thoughts

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s