Click here to Skip to main content
11,926,429 members (57,759 online)
Rate this:
Please Sign up or sign in to vote.

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


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
Prasad Khandekar 18-Mar-13 8:09am
Hello Shruthi,

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

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

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...
ryanb31 18-Mar-13 9:02am
What is editColDR?
Sheikh Muhammad Haris 18-Mar-13 9:32am
show you dropdown aspx code here

1 solution

Rate this: bad
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

Sheikh Muhammad Haris 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.151126.1 | 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