Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am having a dropdown and values in it are say for ex:

1
10
2
20
3
30
4
40
5
50

then i am actually doing edit in my page so whenevr a person clicks on edit it should show the value that was selected in dropdown so for that i am first binding all values in dropdown and then using a jquery line like this:

$("#tbl_ddlcolumnname option:contains("+editColDR+")").attr("selected","selected");


where tbl_ddlcolumnnam is dropdown id and that value that needs to be selected i am getting it in the variable editColDR but .....

the main issue is suppose 5 was selected and during edit after this line executes it shows 50 as selected or... if i had selected 1 ... during edit it shows as 10.....

Why is this problem arising? :) please help!!!

thanking u in advance!!
Posted
Updated 18-Mar-13 1:49am
v2
Comments
Prasad Khandekar 18-Mar-13 8:09am    
Hello Shruthi,

How about using $('#tbl_ddlcolumnname').val(editColDR).

Regards,
Shruthi.BT 18-Mar-13 8:17am    
hi... but that dropdown is binding dynamically ... so i will not have any value.. there will be only text... will this line
$('#tbl_ddlcolumnname').val(editColDR).

work.. ? without any value for the dropdown texts? please help!!
Prasad Khandekar 18-Mar-13 8:23am    
Hello Shruthi,

You already have value in editColDR, isn't it? If binding is happening on the server side and it should have selected the correct option.
Shruthi.BT 19-Mar-13 5:45am    
thank u .. Prasad Khandekar .. the solution worked...
ZurdoDev 18-Mar-13 9:02am    
What is editColDR?

1 solution

Try to bind dropdown with Value property, where editColDR would be value of your dropdown.

and then use this javascript

JavaScript
$('#tbl_ddlcolumnname').val(editColDR)
 
Share this answer
 
Comments
[no name] 20-Mar-13 19:07pm    
Thanks man :)

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