• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 514
  • Last Modified:

AJAX Cascading dropdown Set a value

Hello Experts,

I have 2 dd lists and populate via a web service. And write the selected values to a SQL table.  Which works fine.

The issue is when I read from the SQL table and want to populate the dd list with the corresponding text value. the SelectedValue of the dd list is not working in the page load.

I have unique values stored in the xml (which the web services uses) for the 2dn ddl and
store the integer on the table rather than the text which is displayed in 2nd ddlist.

Do I need to store both the dd list 1 and dd list values  in sql and then create a web service function that will pre populate the the 2 dd lists based on my table values?  Or am I on the wrong track?
 



 

Any Ideas?

 I looked at the EE question/solutions but did not find any ideas.  C# if possible but will take anything!

0
nowmbie
Asked:
nowmbie
  • 2
  • 2
1 Solution
 
vaidhyanathan1Commented:
Two checks to be made. 1) Make sure that you handled page post back properly, that is your ddl selectvalue should be with in !ispostback. 2) set the ddl value like ddl.Items.FindByValue("stringforselectedvalue").Selected = true
0
 
nowmbieAuthor Commented:
Hi,
 Well I am in the !ispostback. And I tried the FindbyValue but It seems that the ddl has no rows in it.
 I am loading it via a web service and using a CascadingDropDown AJax control extender.

It seems that  web service is not called to load the first ddl until  the user selects from the Frist ddl then the second ddl is loaded.  I am probably tired and missing something really simple. But should I create a function in the web service to load the 2 ddls? I mean is there a technique I am missing?

Thanks

0
 
vaidhyanathan1Commented:
It seems to me that you should preserve the second ddl value in a viewstate or session and after having AJAX call to load the second ddl, you should set the value. Alternatively, while retrieving values, you should make an external call to the AJAX web service to load the details based on first ddl value and then set the second value.
0
 
nowmbieAuthor Commented:
Thanks, What I did was load a dictionary by creating a function in the web service and calling from code behind.
0
 
samsymonCommented:
if you have used update panel make sure that both the dropdown list is inside it.
also check AutoPostBack="true"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now