1,761 articles and 13,720 comments as of Saturday, November 13th, 2010

Tuesday, October 6, 2009

Filtering a SharePoint Data View – Part 1

Filtering a SP Data ViewGuest 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:

Filtering a SP Data View

Then create a second custom list named categories.

The categories list doesn’t need any extra columns – just add some items.

Filtering a SP Data View

Now add some items to the todo list

Filtering a SP Data View

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.

Filtering a SP Data View

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.

Filtering a SP Data View

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.

Filtering a SP Data View

Select the settings as follows:

Filtering a SP Data View

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:

Filtering a SP Data View

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.

David SevernGuest 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.

View all entries in this series: DavidSevern - Filtering a Data View»
Entries in this series:
  1. Filtering a SharePoint Data View - Part 1
  2. Filtering a SharePoint Data View - Part 2
  3. Filtering a SharePoint Data View - Part 3
 

Please Join the Discussion

8 Responses to “Filtering a SharePoint Data View – Part 1”
  1. Heather Russell says:

    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?

  2. 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.

  3. 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

  4. pl7626 says:

    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,

  5. Swati says:

    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!!

  6. Benj says:

    Is there anyone who found a solution about the duplicate items problem in the drop down list?

Trackbacks

Check out what others are saying about this post...
  1. SharePoint Kaffeetasse 128…

    Tipps How to remove the anoying password prompt when downloading Office documents from Sharepoint Install…

  2. SharePoint Kaffeetasse 128…

    Tipps How to remove the anoying password prompt when downloading Office documents from Sharepoint Install…




Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!