locked
CascadingDropDown with RequiredFieldValidator not working RRS feed

  • Question

  • User758457977 posted

    Greetings.  I have two drop down lists and one of them has an associated CascadingDropDownList control associated with it:

    ddlFieldA
    ddlFieldB
    ccdFieldB

    I also have a RequiredFieldValidator targeted at ddlFieldB. 

    When a user selects an item in ddlFieldA, ccdFieldB uses a web service to populate ddlFieldB.  I'm using the following method in the web service (pseudocode):

    List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
    if(someConditionExists)
    {
          //I'm using true to set this as the default value
          values.Add(new CascadingDropDownNameValue("First Value", "First Value", true); 
    }
    LoadOtherValuesFromDB(values);

    The drop down list is being populated correctly, and if(someConditionExists), the text in the FieldB drop down list is displayed as "First Value".  My problem is that, although the text is displaying correctly in ddlFieldB if(someConditionExists), it appears that its selectedValue must still be set to null because the RequiredField validator shows the "*" sign next to ddlFieldB after the above code is executed.  I need the selected value to be set so the RequiredField validator isn't activated after the call to populate the drop down list.  Any thoughts?  Thanks.

     

    Wednesday, June 2, 2010 1:27 PM

Answers

  • User-519136805 posted

    Are you using Update Panel for this cascading...if yes than put it as that it will cover all the control that u r using to achieve this...

    ddl , textbox & validators n all...so that parsial postback will update the control state that is inside the updatepanel..

    this might be one of the cause.. give a try...

    if still facing problem that post your full aspx code that is for cascading...



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 3, 2010 1:47 AM

All replies

  • User957549263 posted

    Hi,

    Any chance you could post the code for your two DropDownLists, Cascading DropDownList and the web service?

    Will make it easier for me to follow the workflow.

    Zam 

    Wednesday, June 2, 2010 3:21 PM
  • User-519136805 posted

    Are you using Update Panel for this cascading...if yes than put it as that it will cover all the control that u r using to achieve this...

    ddl , textbox & validators n all...so that parsial postback will update the control state that is inside the updatepanel..

    this might be one of the cause.. give a try...

    if still facing problem that post your full aspx code that is for cascading...



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 3, 2010 1:47 AM