0

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?

1 Answer 1

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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