The Data View Web Part is a great component to use to create user interface elements in SharePoint as an alternative to the Document Library / List UI. But you still want to give users access to the relevant List Forms; Add, Edit, Display.
This is easy enough to do by creating a link to the form required, for example the edit properties form as shown:
<a href='http://server/site/Document Library/forms/EditFom.aspx?ID=1'>Edit Properties</a>
However when clicking OK or Cancel on the List Form, by default you are redirected to the parent list or document library. In order to be redirected to another location after clicking OK or Cancel you can make use of the “source” query string parameter. Essentially you provide the redirect location URL as the source query string parameter in the URL of the List Form. This is well documented and many SharePoint forms accept this parameter.
Now, back to our Data View Web Part, to create our link to the edit properties form for an item and have it return to the page with the DVWP instance on it we need to create an image link to the correct form URL and append to it the URL of the current page.
The snippet below will do just that;
<span style="cursor:pointer; padding-right:8px;"
onclick="javascript:window.location='/{@FileDirRef}/Forms/EditForm.aspx?ID={@ID}&source='+window.location">
<img src="/_layouts/images/edititem.gif" alt="edit properties" align="absmiddle" /></span>
The snippet creates a span with an OnClick handler and embedded image. The OnClick handler navigates to the URL created from;
- @FileDirRef - the server relative path to the (document library in this case) item
- The edit properties form (/forms/EditForm.aspx)
- The ID query parameter supplying the ID of the item using the @ID field
- The source query parameter using the current location supplied by window.location.

RSS - Posts
My