How to reset cascading drop down list back to its prompt text?

Last post 06-13-2009 6:44 AM by Fretwire. 5 replies.

Sort Posts:

  • How to reset cascading drop down list back to its prompt text?

    06-30-2008, 6:54 PM
    • Member
      24 point Member
    • legz11
    • Member since 06-24-2008, 5:35 AM
    • Posts 46

    Hi,

    I'm using cascading drop down lists rigged up to web service. They are part of a form and the user can choose to cancel adding or updating the record in the database.

    I want to reset the drop down lists to their original prompt text. For example "<select an institution>"

    I have tried to set the selected index, also ddl.items(0).selected = true and re-binded the data before the call to no avail.

     I have also tried the following:

    ddlInstList.DataBind()
    ddlInstList.ClearSelection()
    For Each LI As ListItem In ddlInstList.Items
          If LI.Value = "99999" Then
                    
    LI.Selected = True
          End If
    Next

    And also, here is the ccddl code

    <cc1:CascadingDropDown ID="ccddl1" runat="server"

    ServicePath="CascadingDropdown1.vb.asmx"

    ServiceMethod="GetInstitutions"

    TargetControlID="ddlInstList"

    Category="Institutions"

    PromptText="< select institution >"

    LoadingText="Please wait..."

    PromptValue="99999" >

    </cc1:CascadingDropDown>

    Any suggestions apprieciated? 

     

     

  • Re: How to reset cascading drop down list back to its prompt text?

    07-02-2008, 10:10 PM
    Answer

    Hi Legz11,

    When we want to set the selected item on server side, please set the DropDownList and CascadingDropDown's SelectedValue property.  Also, we can reset the DropDownList's selectedIndex on client by using Javascript.  For example,$get("<%=DropDownList's ClientID%>").selectedIndex = value;  It should be executed on client.

    Best regards,

    Joanthan

    Jonathan Shen
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: How to reset cascading drop down list back to its prompt text?

    07-06-2008, 6:57 PM
    • Member
      24 point Member
    • legz11
    • Member since 06-24-2008, 5:35 AM
    • Posts 46

    Thanks Jonathan I will give that a go and respond.

  • Re: How to reset cascading drop down list back to its prompt text?

    07-25-2008, 10:21 AM
    • Member
      164 point Member
    • pwilson
    • Member since 06-28-2006, 9:04 PM
    • Posts 40

    Any luck with this?

  • Re: How to reset cascading drop down list back to its prompt text?

    06-10-2009, 6:54 AM
    • Member
      10 point Member
    • Fretwire
    • Member since 03-14-2009, 8:14 AM
    • Posts 39

    Hi Jonathan,

    Sorry to resurrect such an ancient thread, but I'm trying to do something similar, (ie reset the ccd from the client side), but can't make your solution work. 

    I add this code snippet:

    $get("<%=BusinessUnitDropDownList%>").selectedIndex = 0;

    However this gives me a runtime error:

    The Controls collection cannot be modified because the control contains code blocks (i.e. <%...%>).

    Do you know what's causing this error?

    Thanks,

    Paul

     


  • Re: How to reset cascading drop down list back to its prompt text?

    06-13-2009, 6:44 AM
    • Member
      10 point Member
    • Fretwire
    • Member since 03-14-2009, 8:14 AM
    • Posts 39

    Answering my own thread:

    It seems, for reasons that passeth all understanding, that if you move the javascript from the head to the body, the problem goes away!

Page 1 of 1 (6 items)