Freigeben über


ASP.NET Controls Filter the Data View

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.

-John

Comments

  • Anonymous
    March 07, 2007
    Thanks for the tip. Have you looked at whether it is possible or if there are any issues with Ajax enabling this solution with the UpdatePanel? Thanks, Barry

  • Anonymous
    March 09, 2007
    The comment has been removed

  • Anonymous
    March 09, 2007
    Glad to hear it. It would be nice not to pull back down the master page on a refresh within the UpdatePanel. Barry

  • Anonymous
    March 14, 2007
    How can i set a default value like "Please make an selection" ?

  • Anonymous
    March 15, 2007
    Yes. You need to set the properties on the dropdownlist control to do that.

  1. Select the control
  2. click on Task Panes > Tag Properties
  3. change the AppendDataBoundItem to be True
  4. Click the Smart Panel > Edit Items
  5. click "Add"
  6. type "Please make a selection" for the Text property
  7. Click "OK" That'll do it for you.
  • Anonymous
    March 21, 2007
    Thanks John, That does the trick. One other question: how can i use the asp.net control to control a listview webpart? I cannot create a new filter in a webpart, only choose from values. Paul

  • Anonymous
    March 21, 2007
    Hi, thanks for a fantastic article! Very helpful. I have go this working with Dropdown, but can't get it working with either checkboxlist or radiobuttonlist....is there something special I need to do for those please? Thank you.

  • Anonymous
    March 22, 2007
    The comment has been removed

  • Anonymous
    March 22, 2007
    Sorry I didn't see these comments in time to respond one at a time...

  1. Paul, you can't use this with ListViews because they don't take parameters in for filtering.
  2. Adam, yeah, you need to code the ParameterBinding by hand, unfortunately. When you follow the above steps, you should have a <parameterbinding location="dropdownlistbox1" .../> tag in your page. You need to change that to this: <parameterbinding location="checkboxlist(checked)" .../> where 'checked' is the property on the control you want to evaluate.
  3. Brian, undortunately, not OOTB in this release. You can do this via Javascript, though, if you search live.com for something like "onchange javascript filter drop down". Sorry I'm not more help on that one.
  • Anonymous
    April 19, 2007
    How to filter in a ListFormWebPart?

  • Anonymous
    April 20, 2007
    The comment has been removed

  • Anonymous
    April 20, 2007
    John, Could you clarify your response to Adam about filtering based on a checkbox?  I have not been able to get it to work. When I follow your steps for filtering on the dropdown, the ParameterBinding looks like this: <parameterbinding... location="Control(DropDownList1)" .../>  [note the Control(...)]

  1.  Do we keep the Control(...) for the checkbox, or does it go away?
  2.  Is 'checkboxlist' in your example the id of the checkbox list?  The reason I ask is that there is an <asp:checkboxlist> control. I have tried the following variations without success: <parameterbinding... location="chkID(Checked)" .../> <parameterbinding... location="Control(chkID(Checked))" .../> <parameterbinding... location="Checkbox(chkID)" .../> Thanks, Brian
  • Anonymous
    April 20, 2007
    Here I go again providing a solution my own question.  I didn't have any luck with the ParameterBinding, so I replaced the WebPartPages:DataFormParameter (that was created when I added the filter) with an asp:ControlParameter. <asp:SqlDataSource... SelectCommand="SELECT * FROM [Table] WHERE [BooleanColumn] = @Condition&gt; <SelectParameters> <asp:ControlParameter Name="Condition" PropertyName="Checked" ControlID="chkTest" DefaultValue="False"/> SelectParameters> </asp:SqlDataSource> Where 'chkTest' is the id of the checkbox on my page, and 'Condition' is the arbitrary name I gave the parameter. Cheers, Brian

  • Anonymous
    April 20, 2007
    The comment has been removed

  • Anonymous
    April 29, 2007
    Great post - just what I needed. Is there a way to allow for "All Items" to be returned. I have added a default Item to the list and updated the AppendDataBound Items = "true". This gives me a dropdown with choices "All Items" and then my list of choices, but I want the defualt view "All Items" to return all itmes in the list and not filter them, and then for the user to be able to filter the results. Is this possible?

  • Anonymous
    April 30, 2007
    Hi, Is there a way to have distinct values in the dropdownlist?

  • Anonymous
    May 01, 2007
    I've used the SPD treeview control with success EXCEPT that, try as I might, I can not figure out how to change the font color and hover color of the linked nodes. I think I've changed every style on every style sheet and changed every NodeStyle parameter the TreeView has, yet the text remains blue. Worse is that the colors do change in Sharepoint Designer but not when I view the font in IE. Can you shed any light on this? Thanks.

  • Anonymous
    May 08, 2007
    I am trying to do the same thing, but my column in drop down list is it self a lookup filed. The values shows up as "1;#TEXT" with out quotes. Is there any way to work with this scenario? Mat

  • Anonymous
    May 16, 2007
    Hello ! I have the same proble that JulesAnime, wanted to be able to show all the records before being leaked(filtered) on having changed the value of the dropdownlist. There is way of putting a value for default type ' all items' ? Excuseme , i don´t speak and wrote well in english. Thanks

  • Anonymous
    May 17, 2007
    The comment has been removed

  • Anonymous
    May 18, 2007
    I can do this for WSS 3.0 sites, but cannot for WSS 2.0 sites. :-( The "Insert Data Source Control" option is grayed out for WSS 2.0. How would I do this in WSS 2.0 or I can't?

  • Anonymous
    May 22, 2007
    How to add access database in sharep point designer?

  • Anonymous
    May 23, 2007
    Just What I was lookinf for.. Thanks! This link did the same for me on WSS 2.0 for those that are interested http://wss.collutions.com/Lists/FAQ/DispForm.aspx?ID=202

  • Anonymous
    June 07, 2007
    I have a question like this and i want to create a view based on those two Say list1 and list2 - list1 is similary to category list, list2 similar to product list however list2 has lookup field for list1 but can include multiple values from list1 in that field, it's like product belongs to multiple categories (for a given product you can specify multiple categories) now I want to have a view, that there's a list1 (category) drop down that you can select a category and then the products having that category should be listed below. (here this is many to many relationship) i tried using your way but it didn't work for me) tell me on how to do this, and remember that product (list2) has lookup field for category( list1) where you can select multiple categories for single product Thanks

  • Anonymous
    June 15, 2007
    How to do filter in a ListFormWebPart?

  • Anonymous
    June 25, 2007
    Rasika: Take a look at this demo.  It has a solution for part of your question: http://office.microsoft.com/home/video.aspx?assetid=HX102200491033&width=0&height=0&startindex=4&CTT=11&Origin=HA102199841033

  • Anonymous
    July 09, 2007
    How do I access the element selected in the drop down list?

  • Anonymous
    July 12, 2007
    The comment has been removed

  • Anonymous
    July 16, 2007
    The comment has been removed

  • Anonymous
    July 16, 2007
    Hi, I need an urgent help. I have an aspx page where i have 2 textboxes and 1 drop down list. I have a dataview for which the datasource is from a custom list- Assets. Also the drop down populates values from another list - Asset Type. By default i want the dataview to display all items. Whenever i enter any filter criteria, i want the rows to get filtered. I have created 3 parameters - 2 for text boxes and 1 for drop down. Kindly advice how to proceed, b'coz when i gave % as the default value for these parameters i checked in the DB , when the query was executed the comparison was done - LIKE '%[%]%. I am not able to remove the [] brackets. Please advice Regards, sowmya

  • Anonymous
    July 28, 2007
    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?

  • Anonymous
    August 14, 2007
    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!
  • Anonymous
    August 14, 2007
    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.

  • Anonymous
    August 18, 2007
    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 ??????

  • Anonymous
    August 29, 2007
    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

  • Anonymous
    September 07, 2007
    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 Thanks!

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

  • Anonymous
    September 15, 2007
    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?

  • Anonymous
    September 18, 2007
    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.

  • Anonymous
    September 18, 2007
    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?

  • Anonymous
    September 19, 2007
    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.

  • Anonymous
    September 19, 2007
    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.

  • Anonymous
    September 19, 2007
    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.

  • Anonymous
    September 20, 2007
    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.

  • Anonymous
    September 28, 2007
    The comment has been removed

  • Anonymous
    September 30, 2007
    Preview error: I can manage in SHD steps 1-21 according to the description and it shows data in design mode but when I try to Preview in the browser  it writes: An unexpected error has occurred. Troubleshoot issues with Windows SharePoint Services. Where could be a problem? Other aspx pages (NewForm.aspx etc.) are ok.

  • Anonymous
    October 01, 2007
    Robert, to get MOSS errors edit the web.config: Set CallStack to true in SafeMode <SafeMode MaxControls="200" CallStack="true"... Turn off custom errors <customErrors mode="Off" /> Note: it is recommended you only do this on test/dev systems

  • Anonymous
    October 08, 2007
    The comment has been removed

  • Anonymous
    October 12, 2007
    The comment has been removed

  • Anonymous
    October 13, 2007
    ok, it looks like it needed a IISRESET or so. the above solution is working with textbox. Jan

  • Anonymous
    October 16, 2007
    Is there a way to list only distinct values within a DropDownList using a SP list for the Datasource?

  • Anonymous
    October 22, 2007
    Hi there, i have a problem. I tried to filter a data view with a drop down list. Ive done like stated above but it wont work. I dont understand why. Has somebody a tip for me?

  • Anonymous
    October 22, 2007
    <xsl:param name="FilePath" /> <xsl:param name="Param1">Vista</xsl:param> ... <xsl:variable name="Rows" select="/table/data/row[contains(normalize-space(col [ 6 ] ), $Param1)]"/> Here some code from me. If the default value of the drop down list is vista the filter works but whatever i select in the drop down list the page reloads and the data view is filtered with vista.

  • Anonymous
    October 23, 2007
    Hi, if i use only SharePoint Lists like in this article it works. I use a xml data source and i think this is the problem. Somebody an idea?

  • Anonymous
    October 26, 2007
    Is there any way to make the filter optional?  Meaning is there any way to allow the user to see all rows in the list?

  • Anonymous
    October 30, 2007
    The comment has been removed

  • Anonymous
    October 30, 2007
    Hello there, I've this problem that I just can't seem to resolve: I put a control with an sqldatasource just like this: <asp:SqlDataSource runat="server" id="Interlocuteur" ConnectionString="blabla" ProviderName="System.Data.Odbc" SelectCommand="SELECT * FROM Annuary WHERE  Annuary.SocietyName=@newparameter"> <SelectParameters> <asp:controlparameter Name="newparameter" ControlID="TextBox1" Type="String" DefaultValue="k"/> </SelectParameters> </asp:SqlDataSource> but I get an error on my page, it doesn't seem to know the value of my Control

  • Anonymous
    October 30, 2007
    The comment has been removed

  • Anonymous
    November 06, 2007
    Hi, I'm trying to filter a Data View, which i have place in a DispForm, with a sharepoint control  (SharePoint:ListItemProperty). I have created the paramenter with this control, but it doesn't works. Why? Any idea? thanks,

  • Anonymous
    November 08, 2007
    I have a SQLDataSource that I need to pass the current user name to in order to filter the data.  Can someone suggest a solution?

  • Anonymous
    November 21, 2007
    Is it possible to use this ASP dropdown on a Custom List Form in Sharepoint?  I created a new Form that works fine when I click New on the wss calendar, but when I try to the asp dropdownlist, I get an "unexpected error". Any thoughts?

  • Anonymous
    November 28, 2007
    I have a sql view data source on a page and I've also added a date filter.  My data source has begin and end date columns.  I'd like to be able to select and date from the date filter and have all rows displayed where the date selected is between the begin and end date.  Can the value from the date filter be accessed by the data source filter using a parameter? I haven't been able to make this work.  Any suggestion would be appreciated.  

  • Anonymous
    December 20, 2007
    The comment has been removed

  • Anonymous
    January 16, 2008
    The comment has been removed

  • Anonymous
    January 23, 2008
    Hi, great post!! Of course its not working exactly as planned... I have two drop-downs filtering one list - it works fine with this xslt filter: [(@Category = $Param1 or $Param1 = '(All Categories)') and (@Community = $Param2 or $Param2 = '(All Communities)')] HOWEVER, when the page is FIRST loaded, the default results aren't shown - it is blank. I guess I could solve this by loading the page and automatically posting back, but this obviously isn't a good idea. Is there any way to have the results of the filter be shown on the page when it first loads? Thanks!

  • Anonymous
    January 25, 2008
    Okay, I answered my own question, sort of, I have a work around anyways. In addition to what I did as explained above, I also did what the poster said on March 15, 2007 7:38 AM. I appended an item called "-- Please select a value --" but in the VALUE field put in the '(All Communities)'. Seems to work, now when the page loads I still have all of the default values showing up. Dave #2

  • Anonymous
    January 30, 2008
    All of this doesn't work as soon as you use a wss 3.0 masterpage. It works fine in an empty aspx page. With the masterpage the parameter is always set to default and never picks up the actual selected value of the formfield.

  • Anonymous
    January 31, 2008
    The comment has been removed

  • Anonymous
    February 01, 2008
    Hi Jon, I have reviewed your Demo's six part series.  I thought they were very helpful.  Thank you. I just started working with SharePoint.  I have bought books on sharepoint and browsed ther internet for information.  I have some ASP.Net experience. Two things I need to do right a way is design a great looking master page using a team template and the other is to allow internal company users and unkown users to our SharePoint site perhaps using Forms authentication, login/register.  I'm not sure if I'm going to use SQL server asp provider. Can you point me in the right direction on these two items?.  Any videos on them?   Thank you.

  • Anonymous
    February 03, 2008
    Hi John,         Can we use a similar approach to filter a datasource inside a DataFormWebPart ? Let me give you the scenario, I've got a department list and a section list on my Site. I want to customize the newform of another list to be able to add Cascading DropDown Functionality for selecting a section ( Department->Section) as follows:

  1. Created a datasource (1) to pickup all departments ( Note that Department Field does not exist in my actual list, only Section Field )
  2. Connected an ASP.Net Dropdownlist to the Datasource (DropDownList1) with AutoPostBack
  3. Create another datasource (2) to pickup the sections - Here I inserted {DepartmentName} as parameter in the CAML Query of the Select Method
  4. Linked the Parameter using ASP:ControlParameter to the DropDownList1.
  5. Added a Sharepoint:DataViewDropDownList, linked to the Section Field of the actual list and also linked to datasource (2) Issues: On opening the form, the list of departments and sections are filled correctly. When selecting another department, postback is performed but the section list does not get refreshed. Is there a fundamental thing I've missed out or this kind of implementation not possible ? Thank you
  • Anonymous
    February 19, 2008
    Is there any way to use the following field as input for the filter? <SharePointWebControls:TextField FieldName="Company"  runat="server" id="TextField1"></SharePointWebControls:TextField> We tried to do the same trick with  Control(TextField1,Text) but this isn't working. Regards, Mark

  • Anonymous
    March 04, 2008
    The comment has been removed

  • Anonymous
    March 05, 2008
    Hi, The drop down filter is not quite working for me.  It seems like it only work when the page is a postback.  I can't get the default value to work.  When I first load the page, I don't see anything.  Then when I change the value of the dropdown, I see my item filtered correctly. Any idea? Thanks, gbelzile

  • Anonymous
    March 15, 2008
    The comment has been removed

  • Anonymous
    March 24, 2008
    Has anyone figured out how to get the select all feature to work yet?

  • Anonymous
    March 26, 2008
    Hello everyone, Try as I might, I can not figure out how to change the font color on the Quick Launch menu on the left-hand side of the site. I've successfully changed the font color in the .css code and made sure it was so when I right-click the quick lauch area to modify the style (to the color white that I want it to be instead of that default blue);the text color do change in Sharepoint Designer but not when I view the font in IE- it remains blue. Would anyone be able to shed any light on this? Thanks

  • Anonymous
    March 26, 2008
    The comment has been removed

  • Anonymous
    April 07, 2008
    HI.. i need help i am working on the look and feel of the page using sharepoint designer what i have done is i have copied a default theme(verdant)and made changes to the Cust1011-65001.css and replace the content of "C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATETHEMESCustomBrowntheme.css the changes are seen when the changes are made but when i replace the content of "C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATETHEMESCustomBrowntheme.css and when perform the application pool recycle of that web application and when i opened the Cust1011-65001.css file the number of lines of code got increased by itself and copy of ms-pagetitle was not changing and had a default color # eaffbc was seen  with the default  url of the image even after mnaking the changes again and again the same thing is getting repeated please help shiva.....

  • Anonymous
    April 07, 2008
    John Jansen hope you are doing great i am new to this .....i have 2 issues the one which i just posted and another is that the client is asking me to change the color of the text to black color which is on the side and global  navigation so please tell (guide) me where shoule i do that and how Regards, Shiva

  • Anonymous
    April 07, 2008
    The comment has been removed

  • Anonymous
    April 07, 2008
    Can u please guide me how to set the filter using a Textbox with a Button

  • Anonymous
    April 11, 2008
    Hi all,  i connected a form web part with checkboxes with List web part in Data View web part, this web part is uesd to display the username and the number of checks that user checking from the form, so when user X checks 3 checkboxes , the list will display the username X with the number of choices which is 3. The problem is when user X is loged in again, and checks another 2 choices, i wanted the list to display the user X with 5  choices (by adding 3 + 2) once. but what i get is that it displays user X twice, the first one with 3, and the second one with 5, what i need is to get distinct data in the list. any one can help, please i need to solve this issue as soon as possible :(

  • Anonymous
    April 18, 2008
    Is there anyway to filter useing a date from a datepicker instead of a drop down?

  • Anonymous
    April 21, 2008
    Hi all, need help to set a filter with Textbox and DatePicker here. Only combobox work on my site. Thanks for the help

  • Anonymous
    April 22, 2008
    I am using a calculated column as a source and what I get is string;# before the value. Is there any way to make this disappear?

  • Anonymous
    April 22, 2008
    Hi, I want to display assigned task of currently logged in user while entering time entry in timesheet. In "Tasks Worked On" field, i can see all users tasks, i want to do with share point designer, i m trying to do it from last 10 days, please help...........

  • Anonymous
    April 25, 2008
    The comment has been removed

  • Anonymous
    April 25, 2008
    Hey Darth, Unfortunately, that is not as easy as it sounds. I wrote some jscript to do that once, but it was pretty buggy due to the dynamic nature of the view. In mine, I inserted the checkbox, then converted the Title of a document in the view into an asp:Label control. Then I wrote script that said "for each checkbox, grab the innerText of the next table cell and do something cool". Not great. Someone else who visits here may have a super creative way of doing it, but I haven't really had time to nail one down yet. -John

  • Anonymous
    April 25, 2008
    The comment has been removed

  • Anonymous
    April 28, 2008
    Hi, How do I make this scenario work i SPD:

  1. Calculating a Year based on current date (ex: current date between 8/1/2007-12/31/2007 -> 2007, current date between 1/1/2008-7/31/2008 -> 2008)
  2. Data Source Control referencing a SharePoint List (with field representing Year)
  3. RadioButton list exposing values (from another field in the SP List) filteret by calculated Year Can anyone help ?
  • Anonymous
    May 09, 2008
    To John and spdblog about passing a date as a parameter. Unfortunately, it's not that easy. The SPDateTimePicker control returns the date as a US-formatted string, causing the CAML query to fail. I solved this by creating my own date time control that inherited from SPDateTimePicker and added a SelectedValueISO property that returned the date formatted in ISO format.

  • Anonymous
    May 23, 2008
    For Dropdown list filter in dataview just have a try with this First add the item as  All in dropdownlist and initally in dataview - > rclick ->parameter new parameter let say param1 select  source -> control control id -> urdropdownlist dataview -> rclick filter->add xslt fil -> edit it shows [ ] after [ if u press u ll be getting list of fields there select ur field for example  consider the field as deptID so it should be like this [@deptID = $param1 or $param1 = 'All' ] bye

  • Anonymous
    May 23, 2008
    For Filter through drop down list dont forget to set the property of dropdown list ie AppendDatabounditems   to true

  • Anonymous
    May 29, 2008
    I am new to all of this and need a little help, I have created my custom list and have the page with drowns the way i want it, what do I need to do from there, I have already gone to the NewForm and gon to the main master and replaced it with a custom list so I can see everything in designer, I just need to know how to setup some colums for the drop downs how to link the drops downs..... well everything with kid gloves.

  • Anonymous
    June 01, 2008
    Has anyone managed to get the 'view all items working' as everytime I try this the filter stops working? Anyway got any tips? Thanks

  • Anonymous
    June 06, 2008
    Hai, I have used this for displaying my list of projects in a dropdown in Newform of Contacts list. It worked fine. But now I want to see the value which has been selected in the dropdownlist displayed in the dispform as well as in the edit page the value which has been selected while creation and saved has to be selected. And upodation should also be done when edited. Can anyone help me please? Thanks

  • Anonymous
    July 19, 2008
    The comment has been removed

  • Anonymous
    July 23, 2008
    The comment has been removed

  • Anonymous
    July 24, 2008
    Hello John, I have a filter where in the based on the user profile the page gets displayed. One of the filter has 'R&M' as the text. the filter does not work with the '&' When i change the filter condition to 'RandM' it works. Could  you please help.

  • Anonymous
    August 12, 2008
    Hi, For those of you having trouble binding a parameter to an asp TextBox <asp:TextBox runat="server" id="TextBox1" AutoPostBack="true">, I don't think any comments have addressed this, so I am going to post. To bind a parameter to a textbox everyone was trying to use <ParameterBinding Name="Param2" Location="Control(TextBox1,Text)" DefaultValue=""/>, but this will just return the TextMode when trying to use $Param2.   Instead set the location to Form(TextBox1) <ParameterBinding Name="Param2" Location="Form(TextBox1)" DefaultValue=""/> Now $Param2 will give the value in TextBox1 !

  • Anonymous
    August 18, 2008
    Hi, We have a dataview webpart along with a filter(dropdown) associated with it.. we are facing a strange problem. once we select the value from the filter the data is getting populated in the dataview webpart however the value selected is not getting retained. please let us know the fix for this. Thanks in advance

  • Anonymous
    August 21, 2008
    Hello Friend,                  My problem is regarding editing the Newform.aspx of my list. What i need is  to  autopopulate/autoselect  a dropdownlist according to a selected value in another dropdown. I will explain in detail. I do have a list that contains TaskId and TaskDescription. Say Like T100 taskid corresponds to a task description "Collect Details from a customer", T200 taskid corresponds  to a taskdescription "get Feedback from Customer B".. Likewise.    And i do have another list which have 2 dropdowns Taskid and TaskDescription. What i need is to Autoselect a taskDescription item in TaskDesription Dropdown according to the selected TaskId. Only This change i need to have in Newform.aspx of my sharepoint List.How can i .... Plz help me up...

  • Anonymous
    September 03, 2008
    The comment has been removed

  • Anonymous
    September 04, 2008
    Ok John, you have taught me a good amount of development in Designer. I subscibed to your Total Training Videos and have two question that are very important. you do thie example above with a Dropdown list. I need to do it with a Textbox. You have this on the video training, but when following exactly my filter doesn't return anything after postback? and Second: what is the best way to form (data) validate? I can't find a tutorial, if you could point me in the right direction. thank you in advance, Paul

  • Anonymous
    September 10, 2008
    Hi John! Good Day! I have read from this post that at lot of people are also experiencing the same problem i have, on how to pass the current user name to an SQL Data Source as a parameter. I hope you can share, or anyone from this post, some solutions to it. Thanks a lot! Regards, Noel

  • Anonymous
    September 10, 2008
    Hi, I´m trying to filter a data view based on a textbox input (using "contains" comparison), how can get it?

  • Anonymous
    September 14, 2008
    Not sure a solution was posted to the issue of TextMode being returned from the asp:textbox control when used as a ParameterBinding control. The Location=(Control) is expecting a "Value" property.  Putting Location=(Control, Text) you think would fix it and i've seen it work, but not consistently, So I wrote a quickly extension of the textbox class with a Value Property...  Works great...


Imports System.Web Imports System.Web.UI Public Class TextBoxWithValue    Inherits System.Web.UI.WebControls.TextBox    Public ReadOnly Property Value() As String        Get            Return Me.Text        End Get    End Property End Class

  • Anonymous
    September 17, 2008
    I apologize for my lack or response here. Yes, it turns out that the Textbox control has an issue because it passes its properties to the page in an arbitrary manner. That is: this fails when the TextMode property is passed in before the Text property. Since the order is arbitrary, an IISRESET will sometimes correct it and then another IISRESET will break it again. I have been working on a way to get this working consistently, but as yet have come up empty. As for validation, I simply put an asp validation control on the page (from the toolbox) and use that. You can't use it with FormField controls, but if you convert the FormField into a TextBox, then you can. HTH -John

  • Anonymous
    September 19, 2008
    Hi john Very effective document but i am stuck on some issue,actually i want to create a archive of news and i m picking the data from share point list named news1 how can i do this ,i need your great support to solve this, please help me other i will miss my project deadline. Actually  in my share point list i have columns "newsmonth" and "newsyear". and i have to pick up the news corrosponding to these columns. Please help me regards ram.sharma121@hotmail.com Thank you

  • Anonymous
    September 23, 2008
    Hi, I am trying for multiple filter option. I have taken a simple form webpart, which contains multiple checkboxes. and i have a dataform webpart to apply filter criteria and search the result based on checkboxes selected from form web part. I have written some javascript code to appy the condition and submit the for to url.I am passing parameter through url. I am facing problem to display all the items if no parameters are selected. Please help me. thanks, sharavathi

  • Anonymous
    October 21, 2008
    Hi all, Great blog.  Many of the comments have to do with a drop down filter pertaining to a data view.  Can I perform/set up a similar paramater for formview. I have two tables (employee and interview).  I want to have a drop down list that displays the employee names and shows the corresponding records from the interview table.  I want the ability to edit/insert/update/delete records from the interview table as this time. Thanks, Bobby

  • Anonymous
    November 10, 2008
    I am having the same problem as ribru above.  I can get this to work great on list and Web service datasources but NOT on xml data sources. Please help. James

  • Anonymous
    November 19, 2008
    Thank you! It's just what I was looking for an event listing for my company!! Many thanks.

  • Anonymous
    December 22, 2008
    Hi.. every one in this blog are doing a great job. especially my thanks to John Jansen and other guys who are solving our queries. I had a problem in geting solution for the requirement: Where i am having a data view from cross lists and lists are considering from subsites of a site and with same content type. the problem here is..I want to provide a linkable/clickable column on the data view, where on click of it should redirect to that list item edit view or else to the site where the clicked item list exists(means parent site of that list item). Please can any one solve my requirement. I hope i am clear with the query. Regards Raj

  • Anonymous
    February 02, 2009
    Hello, Similar to the problem Inspire had faced, i am also working on the filtering off of a drop down list It  does filter correctly but it causes an issue with paging. If there are about 1000 rows. The $Rows parameter holds every single row retrieved from the database.   Suppose there are just 50 items matching our filter. Still it returns all the pages with blank items. i dont know how to stop it and sort it so that only the filtered rows are shown. Please help.

  • Anonymous
    February 22, 2009
    Hi John I am new to share point In my page I have 2 web parts with list Items. Web Part1 will have Selected Items Web Part2 will have un selected Items based on field "Selected" Item Name        Selected 1                        Yes 2                        Yes Item Name        Selected 3                        No 4                        No In my web part  have to show a column "Selected" with drop down list with Yes/No Values. When users changes the values it should go to corresponding web part my requirement is I have show drop down list in selected column. when yours selects different value it should go to corresponding web part. Regards Shashank

  • Anonymous
    March 10, 2009
    Hello all, I have a doubt, when i apply filter to didplay data according to dropdownlist value, i want to see complete table intially then it has to filter acording to the dropdownlist value, can any one help in this.

  • Anonymous
    March 11, 2009
    Thanks for the great article. However I am faced with the same issue, textbox control filter behaving unpredictably. Sometimes though an iis reset fixes the issue. Did any one figure out a solution for this? Thanks in advance

  • Anonymous
    March 17, 2009
    I’m trying to filter a list using multiple drop down menus : currency, dimensions and file type. I used the "AutopostBack and controls" method to build the filters. But now I got a problem.  what I need is to be able to get results immediately after each filter is chosen,  and not have to always choose all 3 filters.(the way it works when using the SharePoint filter web parts) That is, If I choose dollar in currency filter I want to get all the “dollar” items, then if I add file type  : jpg I want to see the ones that have dollar and are jpgs. I can’t seem to get it right. If I choose “and” in the data view filter – I don’t get any results till I choose all 3 filters If I choose “or” I end up with all the items that are “Dollar” and also all the “jpgs” instead of items that are “dollar & jpg”. I’m sure there must be a way to get it working.. any ideas ?

  • Anonymous
    March 25, 2009
    I have tried to filter dataformwebpart using a dropdown list as per instructions in this post, however I have not been sucessfull.  My dropdown is a lookp from a sql query from our EPR system (ie Project Number).  I want to filter my document library to only show documents from the Project Number in the drop down list.   Here are the steps:

  1. insert asp.net dropdown, insert datasource (sql query from erp system)
  2. set data field and data text field, autopost back
  3. insert sp doc library as dataview
  4. filter dataview with new param1 from control dropdownlist1 When viewing the page, the document library is not filtered and returns nothing. I've searched everywhere to find how to bind a asp.net dropdown to a sp list of doc library and have had not luck. Thank you for your help. Dan
  • Anonymous
    March 25, 2009
    With respect to my post on asp.net dropdown not filtering,  the filtering works when I use the document library as the datasource for the dropdown, however when I use a sql query for lookup for the dropdown list, the filtering does not work.

  • Anonymous
    March 31, 2009
    HI Im a new comer for this site. I have one questions. I need to create a drop down list on the page and based on that i need to filter a multiple look up. as a example if i select categary1 in the drop down list it should populate the lookup column with the filtered data. Can we do that?? Thanks

  • Anonymous
    April 20, 2009
    Hi thanks for greate article, for me I could filter the data using both specified value or All from the dropdown list control but I found difficulty to use the approach with grouping option in the dataview. Where exactly to place the condition to let the filtering working correctly if we have grouping option in the view. Thanks,

  • Anonymous
    April 27, 2009
    The comment has been removed

  • Anonymous
    May 04, 2009
    Has anybody figured out how to get rid of duplicates showing in your dropdown? There were a few people asking this but I haven't seen an answer, I've tried almost everything to get rid of them. I know I can make seperate lists but I don't want to do that.

  • Anonymous
    May 28, 2009
    Any updates on the textbox problem. It is still a problem. When we use the html control like <input id="Something" name="Something"/> then it reads the value, but if you enable paging, and do a post back then value is not retained and it stops working. We can use javascript and onload event in html to have a workaround. Any direct method of making this work Regard Satheesh

  • Anonymous
    June 05, 2009
    Great post. This exactly what I was looking for.

  • Anonymous
    June 17, 2009
    This helped me sort out an issue, which was related to this parent > child heirarchy, but that was on the same list. I am using this to show a dropdown where user will select an item, and then in the second dataview I am displaying details of that item. However I noticed that I had to create a copy of the list source and used it to populate dropdown and main list source was used to display item. Till now I am only able to display items when I have choose multiple item view settings for dataview. Is there any way around for showing editable view of that item?

  • Anonymous
    June 25, 2009
    The comment has been removed

  • Anonymous
    June 25, 2009
    Hi There, What a great post almost got me to where I need to go. How can you create a drop down based on "Choice Items" created within a column of a sharepoint list? Then send filter values to the second and third drop down list. The last drop down list has to "Send to web part connections" Sorry if this is asking too much at once. Thank you,

  • Anonymous
    July 20, 2009
    Thank you...this was very helpful.

  • Anonymous
    July 23, 2009
    The comment has been removed

  • Anonymous
    August 17, 2009
    Thanks for that tip/help! I have been searching for hours and finally came across this site. It worked like a dream and so easy too!....although I did get a little confused about adding a new page ..I wasn't sure if I should add a normal html or aspx. L earned that SPD converts the basic page to a aspx when saved. Also wasn't sure what you meant about the smart panel, and soon realised this was the little right pointed triangle on the control source added to the page. Anyway, Cheers and thank you!

  • Anonymous
    September 06, 2009
    The comment has been removed

  • Anonymous
    September 07, 2009
    Instead of using ASP.NET control in ParameterBinding use html control and set runat=server and use following code <ParameterBinding Location="Control(txtHtmlTextBox,value)" DefaultValue="" /> This has shown great persistency even if you reset IIS n # time.

  • Anonymous
    September 11, 2009
    Awesome Joel .... this is wat i was looking for .. thanks man appreciate it ...  -Prashanth

  • Anonymous
    September 15, 2009
    Hi Every one I have a requirement  for filter drop down. I have to display the item in drop down in most recently item should comes first. I have a filter drop down called due date. so if any new item inserted in the list than the value of that due date should come first in filter drop down. any solution for this?

  • Anonymous
    September 25, 2009
    I am using Data View Web Part to combine 22 Document Libraries for Corporate View. Everything works fine, expect that the Filter DropDowns have Dupliacte values. Any solution gurus ??

  • Anonymous
    September 28, 2009
    I am using Data View Web Part to show data from 22 Doc Libraries in my page. I have enabled the Filter & Sort features of this Web Part. However the 7 Drop Down Filters are having duplicate values. Please find below the code snippet of the page from SPD,     <xsl:for-each select="msxsl:node-set($dvt_Rows)/[not(@[name()=$dvt_FieldNameNoAtSign]=preceding-sibling::[1]/@[name()=$dvt_FieldNameNoAtSign])]/@[name()=$dvt_FieldNameNoAtSign]">       <xsl:sort data-type="{$sorttype}" /> When I remove [1] from it     <xsl:for-each select="msxsl:node-set($dvt_Rows)/[not(@[name()=$dvt_FieldNameNoAtSign]=preceding-sibling::/@[name()=$dvt_FieldNameNoAtSign])]/@[name()=$dvt_FieldNameNoAtSign]">       <xsl:sort data-type="{$sorttype}" /> My page is not rendered. And I still have the dupliactes in the Drop Downs. Please let me know how to get rid of the Duplicate values. Thanks, Salil

  • Anonymous
    October 06, 2009
    Hi John, perfect article, that was exactly what I was looking for. But I need more :-). Is it possible to filter with DropDownMenu also Gantt view in SharePoint. Because I need to filter data in SubProjects/Task list by Project name and would like to show also Gantt charts for specific SubProjects. Normally it is possible just by making custom view in SharePopint by adding filter parameter, but I want to make it dynamically. Thanks, Michal

  • Anonymous
    October 23, 2009
    The comment has been removed

  • Anonymous
    October 26, 2009
    Filter Data view based on the selected value from Dropdownlist and Radiobutton List 1.Create Paramters <xsl:param name="ListID">AFF375A6-1C8B-4C98-8B0E-60AD2F67C0B8</xsl:param> <xsl:param name="Param1" /> <xsl:param name="Param2" /> 2.Include the control in the Parameter binding <ParameterBinding Name="Param1" Location="Control(cbSoftware)" DefaultValue=""/> <ParameterBinding Name="Param2" Location="Control(rdDocumentType,SelectedValue)" DefaultValue=""/> 3.Add the Filter condition <xsl:for-each select="$Rows"> <!-- Filter --> <xsl:if test "(@Software=$Param1 or $Param1 = 'ALL') and (@Document_x0020_Type = $Param2)"> <xsl:call-template name="dvt_1.rowview" /> </xsl:if> </xsl:for-each>

  • Anonymous
    November 08, 2009
    The comment has been removed

  • Anonymous
    November 18, 2009
    I was able to use the dropdownlist to filter a DVWP where the data source is a SharePoint list. However, when I try to use the process on a XML data source (XML File) it does not work.  There have been a couple of other responses (ribru on 10/30/2007 and James McDowell on 11/10/2008) that indicate the same thing. Yes - autopostback is set to true on the control. I am displaying the parameter in the DWP to see if the value ever changes but it only displays the first value in the dropdownlist even though the dropdownlist shows the value I selected.

  • Anonymous
    December 18, 2009
    Hi, I'm building a simple document approval workflow using Microsoft Office SharePoint Designer 2007 for a document library. One of the requirements is: When a user initiates the workflow for a document he/she must be able to select one or more approvers. I'm using a column called "Approvers" of type "Lookup" with multi-select option enabled. I have a custom list containing a list of users and use this list to populate values for "Approvers" column. When the user selects one or more approvers, I need to create tasks for each one of them to review the document and approve or reject it. Can someone please let me know how to retrieve the selected values from the multi-select lookup column, in the SharePoint Designer 2007, in the workflow design wizard? Thanks, Kal

  • Anonymous
    January 06, 2010
    Urgent, I have two lists,->  the Project list and the Project Task list, When i select any project from the project list, it should display the details of that project and in the other list which is placed just below the project list, all the tasks related to that project. Right now, I am not able to see the List of tasks related to a particluar praoject. Is there any way, where we pass the Project name of Project list to the Project Task List and display filter them by the Project name to display only does tak with the same Project name.

  • Anonymous
    January 06, 2010
    I struggled for 2 days to figure this out! Comes from trying to hard code instead of using the wysiwyg! Thank you! Your help is greatly appreciated!

  • Anonymous
    January 31, 2010
    Hi spdblog!   thanks for this article, i did it correct but after these steps i need to set the selected value for dropdownlist (for now showing the first item of the list) obviously corresponding dataview details on page load. how??? i need ur help urgently.. plz... thanks in advance

  • Anonymous
    February 03, 2010
    Great post. Really helped. Thanks

  • Anonymous
    February 09, 2010
    I am new to Microsoft Sharepoint designer 2007. I tried many times to filter (Common data view task>filter)  the data soruce with created < current date or created <= today -1 , I don;t know where to input. anyone can help.- desperate.

  • Anonymous
    February 11, 2010
    Just what I was looking for!  Thanks for sharing.

  • Anonymous
    February 16, 2010
    John, i chosed spdatasource and Select data field to display in dropdown but it come with all the items from that selected colum like #work,#work,#work,#work,#home,#home instaed of work hone in drop down how to filter this? i will be very thankful of you if you give me right direction.

  • Anonymous
    February 26, 2010
    Similar to Prakash's post of 1/7/10, I would like to set the selected option to the first option in the list.  I've set things up just as directed in the article, but when the page first posts none of the options in the dropdown is selected (I've looked at the HTML via view source).  Therefore, the DVWP shows no matching items. If I select the second item from the dropdown, the selected option property is set, and the DVWP populates with the correct data.  Everything works as advertised from then on. Is there any way of specifying that the first option from a data source should be selected in the dropdownlist control via SPD?

  • Anonymous
    March 10, 2010
    Just to add to the debate above about getting at the value of a TextBox: Someone mentioned that using Location="Form(TextBox1)" won't return anything. That's because the Form value will be held under the name of the control after ASP.Net has rendered the Textbox into an Input tag. So you need to put in the name (not id) of the input tag. View the page source to find it. So you'll end up with something like: Location="Form(ctl00$PlaceHolderMain$TextBox1)" Of course only use this on a page when you know this control is always going to get named consistently - i.e. the control is staying in the same place on a static page. But if you do move the textbox on the page then remember to check it's new name & modify the parameter accordingly. I've found this to be the simplest way to get textbox working as filters.

  • Anonymous
    March 18, 2010
    The comment has been removed

  • Anonymous
    March 18, 2010
    The comment has been removed

  • Anonymous
    June 19, 2010
    Nice post but can anyone provide the solution for duplicated values in teh Drop down.

  • Anonymous
    June 19, 2010
    Nice post. But any solution for duplicated values. Alreday I have specified DISTINCT in the datasource tag but no luck...

  • Anonymous
    June 29, 2010
    The comment has been removed

  • Anonymous
    August 19, 2010
    The comment has been removed

  • Anonymous
    August 25, 2010
    The demonstration was very help ful but I m trying it on content page. Its not happening!

  • Anonymous
    May 08, 2011
    The comment has been removed

  • Anonymous
    February 01, 2012
    Do you know if there is a book or something else about How to use Asp .Net Controls in Sharepoint Desginer 2010? I need some help with the topic because I need to develop a web application using Asp .Net controls, exclusively..

  • Anonymous
    March 18, 2012
    Hi John, How do you do this in SPD 2010?  Thanks

  • Anonymous
    April 11, 2012
    nice post... I was searching this kind of  asolution for  along time. Now i can understand the power of SPD which is more helpful to build the app with out code.... :)

  • Anonymous
    November 30, 2012
    Hi -, I'm trying to figure out how to bind the data source to asp textbox insead of dropdown.. Can you show me how?  Thanks in advance.... by the way .. I'll be glad if you could email me your reponse. my email address is jmj_van@hotmail.com Thanks.

  • Anonymous
    December 23, 2012
    I follwed the steps but only  the value given in default value  is filtering...but values sent from dropdown isnt working.