This is the last post in the series about changing the links (delete, insert and edit). Finally, I'm here to talk about changing the Edit link.
How to…
Replace each "BLOCKED SCRIPT" to: 
The original edit links allows the user to update the data in the data view.
The link looks like that:
<a href="BLOCKED SCRIPT {ddwrt:GenFireServerEvent(concat('__cancel;dvt_1_form_editkey={',$KeyValue,'}'))}">edit</a>
Here we also have 2 options to edit the link.
Option 1: Link to EditForm.aspx
<a href="http://<site name>/Lists/Contacts/EditForm.aspx?ID={@ID}&CancelSource=http://<site name>/Pages/YourPage.aspx&Source=http://<sitename>/Pages/YourPage.aspx"><img src="../PublishingImages/Edit.gif" border="0"></img></a>
Notice:
- I'm using here, as in the previous post, in the CanacelSource and Souce parameters, with full path, in order to prevent the users from visit AllItems.aspx.
- I'm using ID parameter, in order to direct the user to the EditForm.aspx with the correct data.
Option 2: Insert another JS function <!-- Again, my favorite option -->
For this one we will need the IE developer toolbar as well. Steps:
- Display any of your items (DispForm.aspx ). In the tool bar you will find the Edit Item link (next to New Item).
- Open the IE developer toolbar and Click Select element by click.
- Click on the edit link(1), find the a class named ms-toolbar (should be under the second td), copy the href and onclick attributes.
The link should looks like that:
<a href="http://demosrv/Lists/Contacts/EditForm.aspx?ID={@ID}" onclick="GoToLink(this);return false;"><img src="../PublishingImages/Edit.gif" border="0"></img></a>
Notice:
- I'm using ID parameter, in order to direct the user to the EditForm.aspx with the correct data.
- I added the onclick attribute after the link.
Finally, this was the last post in the series, and I hope it was helpful.
Inbar
Hi all,
It has been a while since I have written my last post. Right now, I'm in between exams but I had to take some brake in order to write my second post regarding the link options of data views.
In my last post I have written about changing the "Delete" link in the data view in a way that the user will be prompted before he deletes the item. In this post I will explain 2 way to change the "Insert" links.
Before I'll start it is important to mention that I have changed the links from text to jpg icons. This is how its looks now:

<a href="BLOCKED SCRIPT {ddwrt:GenFireServerEvent(concat('__cancel;__delete={',$KeyField,'=',$KeyValue,'};__commit'))}" onclick="return DeleteItemConfirmation();"><img src="../PublishingImages/Delete.gif" border="0"></img></a>
How to…
Replace each "BLOCKED SCRIPT" to
.
I didn't like the way the insert link allows the user add new items. Personally, I prefer the default NewItem.aspx.
The original insert link is like that:
<a href="BLOCKED SCRIPT {ddwrt:GenFireServerEvent('__cancel;dvt_1_form_insertmode={1}')}">insert</a>
And we have 2 options to change it:
Option 1: Change the insert link to NewForm.aspx
That means that instead of the JS we will write the full path to NewForm.aspx. In addition we need to add 2 parameters to this link: "CancelSource" & "Source". In my testing I have noticed that you need to place the CanacelSource parameter first. Also, notice that the & should be replaced with & .
This is how the link looks like after our changes
If you don't insert these parameters you will notice the following problems:
- Source – When the user will click OK button he will be redirected to AllItems.aspx (or any other default view you have defined).
- CancelSource – If the user will click Cancel button in the NewForm.aspx he will get the following prompted (Invalid page URL) and then will be redirected to AllItems.aspx (or any other default view you have defined).
Option 2: insert another JS function to the link <!--My Favorite option -- >
We will use the IE Developer Toolbar for this. Steps:
Go to AllItems.aspx and open the IE developer tool. In the IE tool click: File>Select Element by Click.
Select the New button (1), Find the td with class named ms-splitbuttontext (2). Then copy the onclick attribute content (3), it should be somthing like that:
BLOCKED SCRIPTNewItem('\u002fLists\u002fContacts\u002fNewForm.aspx?RootFolder=\u00252FLists\u00252FContacts')
Change the link in the data view to the following:
<a href="#" onclick="BLOCKED SCRIPTNewItem('\u002fLists\u002fContacts\u002fNewForm.aspx?RootFolder=\u00252FLists\u00252FContacts')"><img src="../PublishingImages/New.gif" border="0"></img>Add new</a>
I like this way better because you don't need to insert the full path of you NewForm.aspx. This link will lead the user to your page. When he will click OK or Cancel he will be redirected back to your pages.
In my next and final post i will talk about the "edit" link.
I hope this post is helpful.
Inbar
A few days ago I had to give my users access to delete items directly from the data view. I have noticed that the designer's default delete option is missing the validation question "Are you sure you want to delete this item?". This post will explain how to add the delete item link with the prompted question.
In Addition I didn't like the "Insert Item" and "Edit Item" links and I changed them as well – but this is issue for another post.
Adding delete link
After you add a data view to your page choose Data View Properties from Common Data View Tasks menu. In the Data View Properties window, under Editing tab click Show delete item links (I also checked the other options and will talk about them in another post).
You can see that the links are added to the data view:
If you click on the Delete link – the item will be deleted without asking you if you are sure about it.
Changing the link
look for this line in your page:
<a href="BLOCKED SCRIPT {ddwrt:GenFireServerEvent(concat('__cancel;__delete={',$KeyField,'=',$KeyValue,'};__commit'))}">delete</a>
and replace it with (or just add the green text):
<a href="BLOCKED SCRIPT {ddwrt:GenFireServerEvent(concat('__cancel;__delete={',$KeyField,'=',$KeyValue,'};__commit'))}" onclick="return DeleteItemConfirmation();"> delete</a>
The function DeleteItemConfirmation is a function from core.js that ask the user if he's sure about deleting this item.
It is important to say that there is no permission validation in this way – every user can see the delete link. However , if the user will click on the link without suitable permissions he will get the "Access Denied" page.
In the next posts i'll talk about the edit and insert option.
I hope this post was useful.
Inbar
In the previous post I talked about filtering data views with URL parameters. In this post I will deal with filtering the data with ASP.Net controls.
Tip – You can’t insert the control when you point on a web part zone; You can add <br> tag under a web part zone and add the control there.
Here are the steps:
Right-click on the list/library that will supply the values for the control in the Data source library panel. Chose the second option “Insert source data control”. If your prompted to turn on “Visual Aid” click yes. SPDataSource was added to your page.
In the top menu chose Insert > ASP.NET controls > Drop down list, an ASP control was added to your page. Click on the small arrow next to the control, from the Common DropDownList Task menu click Chose Data Source… and then chose spdatasource1, fill in the other fields as shown in the example(In this example I would like to filter according to the title). Click OK and Check Enable Auto Post Back.
Now add your data view (1). Click on the small arrow of the data view, from the Common Data View Task menu chose Filter (2). In the Field Name choose the field that you want to filter by (Document type for this example), in the Value field chose Create new parameter (3).
In the Data view Parameters window, under Parameters source filed chose Control. In Control ID filed chose you control ID (probably DropDownList1),You can add default value. Click Ok and Ok.
5. Save you page and view it in the browser.
– if you reattach you page to layout the control will be lost. The reason is that we broke the connection to the layout when we placed the asp control outside the web part zone.
A few days ago I needed to filter web part with values from a web part that is located in another page. Usually I would have done it with Query String (URL) Filter web part. Unfortunately, my client didn’t have enterprise edition and I had to think of another way to implement this. The answer was (of course) Data view! lets see how it can be done.
Create 2 pages - the first will display the web part with the values, the second will be filter by these values.
Go to your first page and create data view with the values to filter by (in this example documents types).
Now, make the values clickable: Click on the name of the field and choose Hyperlink in Format as… field.
In the address filed chose the destination page (the second page you created – number 1 in the following picture) and add the parameters in this structure: ParmName={@Filed} in this example DocType={@Title} (Number 2 in the following example).
For every parameter you would like to pass in the URL you will need this structure; in order to add more parameters use &. For example: DocType={@Title}&ID={@ID}. Click ok.
- The display name was change – use only {@Title} (or any other filed you need) (Number 3 in the above example).
- The value are now Hyperlinks (next picture).
Reattach the page, check it in and close it.
Detach the second page from its layout and insert you data view. This data view should be the one that will be filter according to the values in the first page.
Click on the small arrow next to the data view and chose filter. Under the field name chose the field that will be filter (in my example – document type); Under value chose Create new parameter…
Data view parameters window will appear. Under Parameters source chose Query String, under Query String Variable enter the parameter you used in the first page as hyperlink (as shown in the following picture). In my example: DocType. You can also add default value. Click OK and then Ok.
You can see that now, there are no items in the web part. For your connivance you can check Show with sample data checkbox (in the Common data view tasks menu).
Reattach the page, check it in and close it.
Now, let’s go to the first page we created. Click on one of the filter values and see the result…
(I clicked on Detailed Design and here is the result…)
In this example I chose to display “document type” in the data view in second page (in addition to the first page). When you’re using data view it is not necessary; But when you are using the browser web parts you have to display these fields in order to filter the web parts.
I find this way much easier to work with (rather than URL Filter web part) because when your working with the filter web part – every time you will edit the page in the SPD the connection will be remove automatically (unless you’re working in code mode all the time).
Hope this post was helpful.
Inbar.
First of all thank you for you kind welcome! Now I need to start working…
I love using Data views! It's very flexible, looks good (if you're doing it right) and you can do a lot of things that aren't available in the custom SharePoint web parts (in the browser).
This post is very basic one – it is the first steps for creating data views. A lot of my posts in will deal with data view so I thought I should start with step-by-step post. Let's start…
Create a page in the SharePoint site and publish it. Go to SharePoint Designer, open you site and then open Pages library. Right-Click on the page you have just created and choose detach from page layout. The idea is that you can edit the page in the designer and later on reattach it to the page layout.
Do not to change the layout components (tables, web parts zone etc’) if you want later to reattach the page to its layout.

Go to the menu bar and chose Task Pane and then Data source library. The data source window will appear in the right side of the screen.

Chose your list / library and click show data.
Select the fields you would like to show in your data view and click insert selected items fields as… .In this example I will use Multiple items view.
before you click insert selected items fields as… make sure that one of the web part zone is selected. If not - just click on it.
Now we have the data view – but what can we do with it?
If you click the small arrow next to the data view – you will see the Common Data view Tasks menu.
Here are some suggestions what to do with this menu:
- Filter – as you filter in the browser and also by parameters. That meaning is that you can choose more parameters to filter by (like URL parameters and more). I’ll explain this in another post.
- Sort and Group – You can group by more than 2 properties.
- Edit columns – to add or delete columns from you data view. They can be added/deleted in the design view as well.
- Web Part connection – with this option you can connect web parts in the same page (also available in the browser) and in another page – a very nice option. I’ll deal with this issue in the future as well.
- Parameters - you can define you parameters (as part of the filter option).
Some tips for customization of the data view:
Link the document name to the document (after all we want the user to see the file…):
- Click on one of the documents name (it is actually the document filed)
- Click on the small arrow that will appear next to the field.
- Change the “Format as” from text to hyperlink.
- When prompted click yes.
- Change the address – click on the (fx) button next to address filed and choose URL Path and click Ok. You will see the filed is now contains: {@FileRef}.
the Text to display filed was changed. You will need only {@FileLeafRef} for this example – so delete anything that you don’t want.
- Click Ok.

Remove the view header – Some customers ask me to hide the view header. When I'm saying "View Header" I mean the row that displays the name of the columns (stroked in the following picture).
There are 2 ways to do that:
- With SharePoint Designer: all you have to do is select this row and delete it.
- CSS – add a new class in your custom css file. Remember this change will be implemented to all of the web parts in the site. If you would like to do that add this to you css file:
.ms-viewheadertr {
display:none;
}
Change the background color of the “Group By”: Although this cell has css class (ms-gv) the background color is defined in the style tag of the td. In order to change the gray background look for background:#cccccc In your code. Here you also have 2 ways:
- Change the #cccccc to another color.
- Delete the background attribute, define the background in a custom css class and then replace “ms-gb” class with your own class. Needless to say that this is my favorite option.
Change the items background color: you probably noticed that the background of the first item is white and second is gray. You can changes this, also in 2 ways:
- Delete it: if you don't want this changing color you can delete it from the code:
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">ms-alternating</xsl:attribute>
</xsl:if>
- Change the css: as you can see in this code every time that the position is odd the data view is using the ms-alternating class. Again – you can add this class to your custom css and overwrite the old one. You can chose another background color or you can replace it with white color (this will be implemented all over the site).
- Another option is to replace the ms-alternating class in the code to your custom css – this will be implemented only in this data view.
When you finish changing the look and feel of you data view save your changes and then right-click on the page name. Chose "Reattach to page layout". If you didn’t change anything in the page layout you will be notice that the page was reattached successfully – Click Ok.
Now check in the file and publish a major version of it. Click F12 to see the page.
To sum up… here is a list of advantages and disadvantages that can help when you don't know which option to choose (Data View or Browser Web Part) .
Advantages:
- Disable “View Header” locally.
- Display data that is not for the same level of hierarchy – That means that in the home page you can display libraries and lists from other site in your site collection.
- More design option and flexibility.
- Group by more than 2 properties.
- Show calculated date base on xsl function (I will deal with this issue in the future).
- On item view.
Disadvantages:
- The end user can edit the web part (it can also be advantage – depend on you dements)
- For every change you will have to open the SPD.
My name is Inbar Cizer and this is my first post. After a long time of thinking about it I decided to do it – to open my own blog.
In my job I'm implementing SharePoint for Omnisys ltd. For a while I had love/hate relationship with SharePoint (aren't we all?) but after a while I realized that I know all kind of tips that, hopefully, can help others. In this blog I'll write about them.
Apart from implementing SharePoint I'm also a student at Tel Aviv University school of mass communication and political science, which is very interesting but have almost nothing in common with my job.
I hope you will find my blog helpful.
Inbar