Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have one drop down list in update panel but when I assign any value to ddl.selectedValue it is not selecting that value

for eg.

C#
ddl.selectedValue=2


then it remains null

i had check it using break point it is not changing to 2.

please help me......
Posted
Updated 5-Jul-13 4:06am
v2
Comments
Nirav Prabtani 5-Jul-13 9:19am    
can you paste your code here???
Prasad Khandekar 5-Jul-13 9:24am    
Hello Jagdish,

Please share your code snippet. On the basic of supplied I can say that the selectedValue is a string property and hence try assigning a string value. Better yet is to use code something like one shown below.

ListItem dlItem = ddl.Items.FindByValue("2");
dlItem.Selected = (dlItem != null);

Regards,
Please show the code of function where you set the value.
Rakesh6906 5-Jul-13 11:30am    
Please share the code..

hay jagdish,

Change your dropdownlist properties AutoPostBack : True
its work..
 
Share this answer
 
I think you can give the property in design page itself.

XML
<asp:DropDownList ID="DropDownListname" runat="server">
                    <asp:ListItem Value="0">first value</asp:ListItem>
                    <asp:ListItem Value="2">second value</asp:ListItem>
                    <asp:ListItem Value="3">third value</asp:ListItem>
                </asp:DropDownList>



Or try

dropdownlist.selecteditem='That String'
 
Share this answer
 
I found that it was databinding error. data was not bound to ddl therefore selected value was empty.


thanx to u all for reply...
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Mar-14 12:07pm    
Not an answer. Such posts are considered as abuse. Use comments instead.
—SA

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