Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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? Smile | :) please help!!!
 
thanking u in advance!!
Posted 18-Mar-13 2:06am
Edited 18-Mar-13 2:49am
v2
Comments
Prasad Khandekar at 18-Mar-13 8:09am
   
Hello Shruthi,
 
How about using $('#tbl_ddlcolumnname').val(editColDR).
 
Regards,
Shruthi.BT at 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 at 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 at 19-Mar-13 5:45am
   
thank u .. Prasad Khandekar .. the solution worked...
ryanb31 at 18-Mar-13 9:02am
   
What is editColDR?
Sheikh Muhammad Haris at 18-Mar-13 9:32am
   
show you dropdown aspx code here

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try to bind dropdown with Value property, where editColDR would be value of your dropdown.
 
and then use this javascript
 
$('#tbl_ddlcolumnname').val(editColDR)
  Permalink  
Comments
Sheikh Muhammad Haris at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 555
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100