Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I am setting selected item of one drop down according to the value of other drop down through javascript.
But I am not getting this selected item value in code behind.
Finally I used Hidden Field for setting the drop down value and then used this hidden field value in code behind.

Can any one explain me this behavior?

java-script code : -

JavaScript
for (var j = 0; j < ddlDataType.options.length; j++) 
{
 if(ddlDataType.options[j].text.toLowerCase() == 
     auditTableColumnsArray[i][0].toString().toLowerCase())
 {
    ddlDataType.options[j].selected = true;
    $get("<%= hfDataType.ClientID %>").value = ddlDataType.options[j].value;
    break;
 }
}
Posted
Updated 20-Sep-12 19:36pm
v2

Have you enabled view state of the dropdown?
if not set "EnableViewState=true" for the control.
 
Share this answer
 
I think u have ur fill drop down method in page load, instead of !ispostback, check it once
 
Share this answer
 
Comments
itskvini 22-Sep-12 1:04am    
Well !IsPostBack, that has been a practice for a while now. So no luck there.
Actually it could not have been an issue if the setting of drop down would have been done on code behind. But we didn't want unnecessary postback. That's why doing it using javascript.

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