4

To make a long story short (too late), we have a dropdownlist that is populated through a list of items. We want to use this dropdownlist to filter the list in a data view web part.

This works great, except on initial page load. Initially on page load, the filtering doesn't happen unless we set the default value of our parameterbindering to something. Right now the binding is:

<ParameterBinding Name="name" Location="Control(DropDownList)" DefaultValue="" /> 

Once you click on another item on the dropdownlist the filtering occurs and it posts back with the correct values. But if you don't feed it a hardcoded default, then it won't filter initially on pageload.

This would be pretty simple if I was able to do server side code (call the postback initially and let it filter itself), but I'm not. The only access I have is client side code or anything I can do in Designer that doesn't involve Server Side Code (ASP, C# is out). Also I'm using Sharepoint 2007.

Is there some way to force the filter to happen on page load? Or can I set the DefaultValue through a javascript function (would be simple enough to place the value of what I want in a hidden input and access it through there)?

I'm also up for any additional ideas! Thanks.

3
  • Do you have a default value configured for DropDownList control?CommentedOct 25, 2011 at 19:16
  • Yes, but it's a static default value. I'm looking for some way to insert a javascript function into the "DefaultValue" portion of the parameterBinding listed above so that I can make it more dynamic. My main goal is to get a filter to apply based on the current selection of the dropdown on page load and not wait for user input to select something.
    – Robert
    CommentedOct 26, 2011 at 11:27
  • I think better way to achieve the requirement is to create a page and fetch the data using JavaScript CSOM and bind the data using JQuery. If you want I can write the code and post it.CommentedJul 22, 2014 at 13:42

1 Answer 1

1

Feel free to check out my blog post series on this topic:

http://mattbramer.blogspot.com/2010/09/sharepoint-integrate-aspnet-controls.html

I cover the whole scenario of setting default values and explain how to manipulate the SPDataSource's CAML. If you need some more help though, feel free to ask.

5
  • Hey, Thanks for the response!. Hm, and Enter apparently saves it. In any case, I went through your blog and in all the steps you outline I've done. In fact filtering works fine when I get around to selecting an option on the dropdownlist. The problem I'm having is that when the page initially loads the filter is not applied to what is currently selected on the dropdown. Essentially, I want the filter to apply the dropdown selection immediately on pageload and not wait until the user selects an option (I didn't see that covered in the articles you linked).
    – Robert
    CommentedOct 26, 2011 at 11:23
  • Have you considered trying to filter based on a query string or something else? When going through all of this myself, I remember needing to force user interaction to start filtering. In this blog post, I talk about that. mattbramer.blogspot.com/2010/10/… It might be possible to dive into the SPDatasource and do what you need. I thought I had that in my posts, but I don't.CommentedOct 26, 2011 at 12:56
  • I get what you're saying in the blog posts. Basically just force the user to make a selection in order to see any data. But I actually have that functionality now without adding a custom selection. I've looked a bit in the datasource's to see if there was some way to force the filter through, but once again I can't see a way to get another param or a javascript function into the default value of the parameterbinding portion to force it up on load.
    – Robert
    CommentedOct 26, 2011 at 14:54
  • I think a query string or a cookie value here would allow you to set a filter on page load. You would have to modify the SPDatasource to allow that parameter within the CAML, but that's not too difficult to do. Do you have an SPDatasource on your page populating your control?CommentedOct 26, 2011 at 17:45
  • Yes, it's currently selecting the values to put into the control.
    – Robert
    CommentedOct 26, 2011 at 18:14

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.