ASP.NET Controls Filter the Data View

ASP.NET Controls Filter the Data View

Rate This

John Hey there,

My name is John Jansen and I'm one of the Test Leads for the SharePoint Designer (SPD) product group. My specialty is data presentation and application building. But I also love to play around with CSS and generic ASP.NET controls. I plan to post tips and tricks here based on questions I see asked in Newsgroups as well as Discussion Boards inside Microsoft.

This first tip is about inserting an ASP.NET control onto a page in SharePoint Designer and then using that control as the mechanism for filtering a Data View on the page. For the purposes of this post, I'm using a DropDownList control because that seems to be the one most people ask about, but you could use a TextBox or CheckBox or anything else and get similar results. The scenario here is that you have a bunch of Categories and a bunch of Products that fit into those Categories, and you want to use a DropDownList to show Products for a specific Category.

To begin, create two lists in the browser: Categories with a field of CategoryName and Products with a field of CategoryName as well (I use a Lookup field type for simplicity, but it doesn't have to be - this code does a simple string compare). Then fill out the lists so you have more than one item in each.

This tip also assumes you already know how to open your Site in SPD and you have created a new page. I realize it is a lot of steps, but I believe they are pretty straight forward as you perform them...

  1. Place your page into design view
  2. Click Task panes :: Data Source Library
  3. Click the data source called Categories
  4. Click to Insert Data Source Control
  5. If prompted, click “Yes” to display the control
  6. Place insertion point below this control
  7. Click Insert :: ASP.NET Controls > Drop Down List
  8. Click the Smart Panel :: Choose Data Source...
  9. Choose the Data Source (for example, SPListDataSource1)
  10. Tell it to display "CategoryName" (or the field that contains your category name)
  11. Make its value "CategoryName"
  12. Click OK
  13. Click to select the dropdownlist control
  14. Click the Smart Panel :: AutoPostBack == True
  15. Drag and drop the Products list onto a page to create a Data View
  16. Clck the Smart Panel :: Edit Columns to add and remove the columns you want to display
  17. Click Data View :: Filter 
  18. Create the following filter:
                    Field: CategoryName (or the field that contains your category name)
                    Comparison: Equals
                    Value: [Create a new Parameter]
                                    Param Name: Param1
                                    Source: Control
                                    Control ID: DropDownList1
                                    Default: Beverages
  19. Click OK
  20. Click OK again
  21. Save the page
  22. Preview in the browser
  23. Make a change to the DropDownList control

OK. That should do it! Good luck.


  • I follow the instruction in article, it works fine. But when I open "Data View Properties" and enable "SharePoint List Toolbar", it doesn't work, when you change drop-down list, the Data View always keeps same. So, how to fix this problem?

  • Hey Chopper and to anyone else who had an issue with the All Items working but the other filter not, try the following:

    1. Smart Panel -> Filter

    2. Click "Add XSLT Filtering..." and then the Edit button

    3. Add the above @CategoryName = $Param1 or $Param1 = '(All)' between the brackets.

    This will get you to where you were in the step above, but without having to go into code.  I did this and had the same problem as you did.

    Turns out, while you can change the column around, and such, sometimes designer doesn't update the column name.  For example, my column was currently named 'Category'.  However, originally my column was named Meeting Type.  Hence the variable was actually being used by my XSLT was: @Meeting_x0020_Type  

    Now, you can dig through your code to find the correct name, or do the following: Once you are inside that XSLT filter window, the left window that is labeled "Select a field to insert".  Browse to your colum you wish to filter by and double click it to insert it.  It will show you the current name in the tree menu, but when you insert it it will give you the actual variable name.

    Hope this helps!

  • Quick update to my above post.  My environment is kind of wonky, so this may not apply to everyone else but:

    If when you first go into the XSLT edit screen inside the SmartPanel -> Filter window, and you see the following tree structure on your left: dsQueryResponse->Rows->Row but then nothing below on rows do the following:  

    After having checked "Add XSLT Filtering" from the Filter screen, save the aspx page again.  Designer doesn't seem to populate the XSLT object browser in the XSLT filter editor screen until the page has been saved with this enabled.

  • I want  to choose the drop down list data source but when in Data Source Configuration Wizard in the first field I select SoapDataSource1 and then there's nothing happen !!!

    ( I'm using a Web Service as my DataSource )

    only the 2 next fields become available but thers's nothing in them and I mean there's nothing to choose for TextField and Data Field !!!!

    What should I do for DataTestField and DataValueField ??????

  • Can someone explain in more detail how one filter a dropdown based on the selection from the first dropdown. I have tried this tutorial at the top and got that working. But then youngbuffett came with a comment about my issue and I have NO idea on how to do this.. Any help would be great

    As I said I have the basic tutorial working but i need this last bit to work. Help :-)

    Contact me on drnibbles at gmail dot com

  • What is the Parameter source and Property name that I need to use to filter by "[current user]" or "Context.User.Identity.Name" when using a SQLDataSource to populate a GridView in SharePoint Designer?  Please email me: sharepointer at gmail dot com


  • Is there a way to have distinct values in the drop down where the data source is referencing a sharepoint list?

  • I am having the same problem as donna, I have this SPDatasource, that is actually a list, and I am using a specific colum that has duplicated values, it's possible to get read of them?

  • I am wondering how do I filter a data view based on a variable in the page.  Currently I have created a Page Layout based on a 'Partner Solution' Site Content Type which has the following Variables (Partner Name(lookup), Solution Name(lookup), description(htmp editor), partner logo(Image Editor), etc...)

    When I create an instance of this page layout for each partner soltuion I want to be able to use the 'Partner Name (lookup)' from the assocated site content type to filter the data view.

    I have tried using the control (as each of the columns in the site content type are defined as controls in the page layout) and system variable (cause control didnt work) and used the id as the vlaue but this still does'nt seem to work.

    I then thought it might be something to do with the postback, wheather it was triggering a event after selection.

  • Hi everybody!

    Thanks for your awesome comments – I hope you have some awesome comments for my problem :)

    I got a Website with a lot of dropdown Lists, which control 3 dataviews and all of them send their information via autopostback to the views. But everytime you choose an option in the dropdown, the postback going to work and send. ( The site actualizes itself. )

    So how do I implement a button to postback manually, to save time and work from the server?

  • Hi all

    I solved my problem and need no help anymore - for now ;)

    So for you the information:

    button > properties > behaviour > potbackurl

    here you have to fill in the url of the site you want to post to.

  • Hi everybody

    This blog is really awesome and has solved most of my queries regarding dropdowns and filtering.

    But I am just wondering as to how a button can be implemented to solve the above problem of multiple postbacks for multiple dropdowns on page as asked by Christian

    And on top of that - Would be really great if I can get an answer to this :)

    How can i get all the filter criterias (like from RadioButtonList1, DropDownList1, DropDownList2, DropDownList3, TextBox etc ) on one page submitted to server on click of lets say 'Search' button ?

    And results of these search criteria displayed on another ASPX page like 'SearchResults.ASPX' with data in grid form or listview form etc.

  • I solved my problem!

    go to the propertiey of your button an you will see "postbackurl" in behaviour. there you simply have to add the url u want to post to and finish!

    the second question is tsimple: just add the url of your searchresults in the postbackurl from the button.

  • I solved my problem!

    go to the propertiey of your button an you will see "postbackurl" in behaviour. there you simply have to add the url u want to post to and finish!

    the second question is tsimple: just add the url of your searchresults in the postbackurl from the button.

  • I've been having difficutly with parameter bindings on a 64bit system.  The same page works differently on 32 and 64 bit MOSS systems.

    The binding:

    <ParameterBinding Name="Surname" Location="Control(Surname)" DefaultValue="%"/>


    <ParameterBinding Name="Surname" Location="Control(Surname,Text)" DefaultValue="%"/>

    seems to be returning the TextMode property value (SingleLine or MultiLine) rather than the value of the text in the text box on the 64 bit system.

    Is this a known problem, has anybody else experienced it and are there any workarounds?


Page 3 of 12 (167 items) 12345»
Leave a Comment
  • Please add 8 and 6 and type the answer here:
  • Post