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...
OK. That should do it! Good luck.
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.
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
I got a question. I would like to filter my DataView with a Text box, which I got it working (kind of). However the text should be case sensitive, in other words if I query in something that does not have the same case, i don't get any results.
Any help would be appreciated.
Shankar, can you share your text box solution with me/us?
I have the following - but its not working:
<ParameterBinding Name="Param1" Location="Control(TextBox1,Text)" DefaultValue=""/>
When I provide a DefaultValue, SPD displays the correct filter result. But on the web page no results show up.
This is my text box control:
<asp:TextBox runat="server" id="TextBox1" AutoPostBack="True"></asp:TextBox>
The only control I get to work is the DropDownList.
ok, it looks like it needed a IISRESET or so. the above solution is working with textbox.
Is there a way to list only distinct values within a DropDownList using a SP list for the Datasource?
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?
<xsl:param name="FilePath" />
<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.
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?
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?
look @ July 28, 2007 5:24 PM
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.
You can define 'All' as default. Works fine for me!
My Problem still remains unsolved. How can i filter XML datasources? With Lists its no Problem but XML data sources it wont work. Only the default filter shows up.
Hope some DEV has an idea.
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">
<asp:controlparameter Name="newparameter" ControlID="TextBox1" Type="String" DefaultValue="k"/>
but I get an error on my page, it doesn't seem to know the value of my Control
Hi my sqlDataSource with the code like this:
<asp:SqlDataSource... SelectCommand="SELECT * FROM [States] where [Country] = @Country">
<asp:controlparameter PropertyName="SelectedValue" Name="Country" ControlID="ddlCountry" />
doesn' t seem to work with Sharepoint, the control doesn't have any value
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?
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?