Click here to Skip to main content
11,412,400 members (67,710 online)
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 OriginalGriff 332
1 Sascha Lefévre 200
2 Sergey Alexandrovich Kryukov 140
3 Maciej Los 135
4 ProgramFOX 130
0 Sergey Alexandrovich Kryukov 9,025
1 OriginalGriff 7,247
2 Maciej Los 3,525
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web04 | 2.8.150414.5 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2015
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