Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ajax and dropdown lists

Status
Not open for further replies.

xanra

IS-IT--Management
Jan 16, 2007
20
US
I've been able to create two cascading drop down lists that take the parameter from the previous control successfully. However is there any way to make it so that the third drop down list can take a parameter from each of previous controls?

Thanks in advance!

-Paul
 
it sure can.

however that depends on how you are doing this. are you using inbuilt controls to do this (ATLAS framework) or do you have complete control over the AJAX code???

Known is handfull, Unknown is worldfull
 
Thanks for the reply and this is with AJAX in 2.0 framework.
 
yes but it will only take a parameter from the previous control, not 2 parameters one from each of the previous two controls.
 
You'll already have your index from the first one selected when you get to the third..... you don't need to pass in anything.... just add it to your select statement

 
I'm confused... my first dropdown list pulls data from a data set.

and then this is the code for my webservice method for the 2nd dropdown list.

Code:
 public CascadingDropDownNameValue[] getSemesters(string knownCategoryValues,
        string category)
    {
        
        string[] _categoryValues = knownCategoryValues.Split(':', ';');
      
        int _site  = (Convert.ToInt32(_categoryValues[1] ));
        
        
        List<CascadingDropDownNameValue> _SiteSession = new List<CascadingDropDownNameValue>();
          
        getSemesterTableAdapters.tblscsemesterTableAdapter _semesterAdapter = new getSemesterTableAdapters.tblscsemesterTableAdapter();
                                   
        
        
        foreach (DataRow _row in _semesterAdapter.getSemester((short)_site))
        {
            _SiteSession.Add(new CascadingDropDownNameValue(_row["semestername"].ToString(), _row["site"].ToString()));
        }
      
        return _SiteSession.ToArray();
    }

then the 3rd dropdown list has the code below but it will not function because it is not picking up the 2'nd dropdown list's values.

The 3rd dropdown list's dataset needs the int value from the 1st dropdown and the string value from the 2nd dropdown.


Code:
public CascadingDropDownNameValue[] getCats(string knownCategoryValues,
       string category)
    {
        
        string[] _categoryValues = knownCategoryValues.Split(':', ';');
   
        int _site = (Convert.ToInt32(_categoryValues[1]));
        string semester = _categoryValues[3];
        
               
        
       
        List<CascadingDropDownNameValue> _Cats = new List<CascadingDropDownNameValue>();
       
                
        getCatsTableAdapters.tblscservicecatTableAdapter getCats = new getCatsTableAdapters.tblscservicecatTableAdapter();

        foreach (DataRow _row in getCats.GetData(semester, (short)_site))
        {
            _Cats.Add(new CascadingDropDownNameValue(_row["servicecat"].ToString(), _row["servicecat"].ToString()));
        }


        return _Cats.ToArray();

 

    }


Thanks in advance!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top