Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to filter the contents of a dropdown based on the selection in another dropdown, using this MSDN blog post and forum post.

The filtered dropdown appears with the correct data the first time the page is loaded, but when I change the first dropdown and the page posts back, the filtered dropdown doesn't change. I imagine it's something to do with the order that controls are created in the lifecycle, but I'm not sure how to fix it.

Here's the code for the filtered dropdown and data source.

<SharePoint:SPDataSource ID="sdsBL2" runat="server"
    DataSourceMode="List"
    UseInternalName="true"
    SelectCommand="<Query><Where><Eq><FieldRef Name='ParentCode' /><Value Type='Text'>{BL1}</Value></Eq></Where><OrderBy><FieldRef Name='Title'/></OrderBy></Query>">
    <SelectParameters>
        <asp:Parameter Name="WebUrl" DefaultValue="/sites/NewsCore/" />
        <asp:Parameter Name="ListName" DefaultValue="Standing Data - BL2" />
        <asp:ControlParameter Name="BL1" ControlID="ddlBL1" PropertyName="SelectedValue" />
    </SelectParameters>
</SharePoint:SPDataSource>
<asp:DropDownList ID="ddlBL2" runat="server"
    DataSourceId="sdsBL2"
    DataTextField="Title"
    DataValueField="Code"
    style="min-width:200px" AutoPostBack="false" />

Can anyone see what I've missed?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

I ended up having to bind the dropdown contents in the code behind file for it to work with other requirements for the form.

If anyone's trying to do it using the code in the question, I found this article which suggests adding EnableViewState="false" to the filtered drop down to force it to get a data set with the new filter, instead of retrieving the old one from the View State.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.