Filtering a SharePoint Data View – Part 1
Guest Author: David Severn
This comes up in the forums from time to time and I have been asked by students and clients how to do this. I have seen it on videos but will simply list the steps here for anyone who needs to easily create a filtered view of a grid of data.
This post will show how to set up the ASP.Net drop down using a SharePoint list as its data source.
The example I will use is a simple categorized to do list.
There will be a ToDo list and a Categories list.
The ToDo list will have a Category column which, for this example, will be a simple single line of text field.
Create two new custom lists one named ToDo with columns as follows:

Then create a second custom list named categories.
The categories list doesn’t need any extra columns – just add some items.

Now add some items to the todo list

Start SharePoint Designer and open the site containing the lists.
Within SharePoint Designer create a new aspx page and name it ToDoByCategory.aspx.
Ensure that this page is opened for editing and then open the Data Source Library Task Pane using the Menu Task Panes Data Source Library.
Expand the Lists to display the Categories and ToDo lists items.
Use the dropdown menu on the Categories list and select Insert Data Source.

Display the Toolbox Task Pane by using the menu Task Panes Toolbox command.
Expand the Asp.Net Controls section then expand the Standard Controls Section.

Click on Your New page to position your cursor.
Then Double click on the Drop Down List icon in the tool box to add the drop down list to the page.
Click on the Choose Data Source menu Item.

Select the settings as follows:

Then press O.K.
Press F12 to display the page.
Press O.K to save changes.
The page should display an ASP.Net Drop Down list with contents of the Categories list as follows:

The next post will cover the adding of the data view and the final installment will show how to filter the data view from the drop down list.
To summarize
We have added a datasource for the categories SharePoint list.
We then Added an Asp.Net drop down list to the page that uses the new datasource and therefore displays the data from the list.
Guest Author: David Severn
David Severn is a Developer specialising in ASP.Net and SharePoint related technologies. He holds various Microsoft certifications including MCTS for WSS Development and Moss configuration. He lives with his wife and three children in the west of Ireland.
- Filtering a SharePoint Data View - Part 1
- Filtering a SharePoint Data View - Part 2
- Filtering a SharePoint Data View - Part 3
David,
I’ve used this method before and I have to say it’s a favorite of mine. Thank you for writing it up. This works very well the way you have set it up — using a separate authority list to store the category data and create the data source from that. Have you ever had any success using, say, a choice field on the main list as the data source? I have a number of places I want to do something like this but end up with duplicates in the drop down, since the choice field is non-unique. Do you have any insights on how to make the choices in the dropdown unique?
Hi David, I have the same question as Heather Russell. “Do you have any insights on how to make the choices in the dropdown unique?”
I did the same thing, but ended up with loads of duplicate values. We did implement a work around and had success. If I didn’t have to use a workaround that would be great.
Thanks.
Hi David,
I have the problem that as I go into sharepoint designer and attempt to insert the data source control that option is greyed out? Why would this be? Would it be because of how I set up the categories list?
Regards
Glynn Williams
Hi David,
Thanks for writing this series. It helped understanding how to apply dynamic filter on the data view.
I’m trying to do the same using a different control. Instead of using the drop down list control that’s available through ASP.NET Controls, I’m using “DateTimeControl” from “Server Controls (Sharepoint)”. When I insert this control, I don’t get any option to “Choose data source” for this control. Would you be able to help?
If you would like to know more on what I’m trying to do, you can check the following post:
http://social.technet.microsoft.com/Forums/en-US/sharepointcustomization/thread/0e3c9e83-0301-4bce-aa67-81f91d613c7c
Thanks,
This is to answer Glynn Williams query about the option being grayed out. I have also observed this several times. However, if you simple save the page and then try this option you will see that it is no longer grayed out!!
Is there anyone who found a solution about the duplicate items problem in the drop down list?