0

i m trying to create a drop down list that takes values on the basis of previous selection from differnt tables in the database. a table of mine has 3 columns : ID , name and 1st entry date i m provide 3 radiobuttons if 1st radiobutton is checked then the dropdown list should show all the IDs present in the table, if 2nd is checked then it should show all the names n so on.. i also want this process to continue i.e. once something is selected from the 1st dropdown list i want another dropdown list to appear with items depending on the previous selection i really dont know how to go about it, i m trying to do this in asp C# & m using sql server 2005 database and i m not good at any of these please help!

2 Answers 2

2

I'm assuming that you're using ADO.NET DataSets for your client-side data, so all you'd need to do is either change the .DataSource property of your ComboBox to be the appropriate table from the DataSet.

1

For the first part of your question you can dynamically change the datatextfield and datavaluefiled according to the radiobutton that has been clicked. if ( radiobutton1.checked ) { dropdownlist1.datatextfield = 'id'; dropdownlist1.datavaluefield = 'id'; } else if ( radiobutton2.checked ) { dropdownlist1.datatextfield = 'name'; dropdownlist1.datavaluefield = 'id'; } ......

for uniquely identifying your selected item in dropdownlist use id as datavaluefield always.

For the second part You can add an event onchange for the dropdownlist and can get the currently selected item and using that item you can set the econd dropdownlist.

Hope this helps.

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.