Click here to Skip to main content
15,850,921 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview with 3 dropdownlists and 2 textboxes.

I want a jquery for the below functionality,
if( ddl1.selection ="1")
ddl2.enabled = true
ddl2.enabled = true

I have the below code like this written in jquery,
$(function() {
        $(".ddl1class").change(function() {
        if ($(this).find('option:selected').text() == "1") {
            //$(".ddl2class").attr('disabled', true);
            } else {
            //$(".ddl3class").attr('disabled', true);

But Iam not able to understand how to find the ddl2 of ddl1's gridview row to be enabled/disabled.

Can someone please help..
Updated 25-Nov-13 0:33am
Peter Leow 25-Nov-13 6:28am    
Is this what you are looking for, check up this link
Member 10217959 25-Nov-13 6:58am    
All the controls are in the gridview, so specifying just like this $("#ddl2class") will not help.

I need to find the row of the ddl1 and then ddl2 in that row and then
set the attribute

1 solution

You could just get the val() from select node for comparison.


look at this fiddle, this should do what you need:[^]
hope it helps.
Share this answer
Member 10217959 2-Dec-13 1:42am    
Thanks a lot. your solution worked for me woth a slight modification.
Instead of "$(this).parent().parent("tr").find", I used "$(this).closest("tr").find"

But now I got into ANOTHER ISSUE, On the posback on a button click, Im losing the dropdown and text values and it is going empty.

Can you help on this as how to retain the values on the postback

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900