Click here to Skip to main content
16,019,055 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
I have created and form in which i have used a user control which contain another user control which contain dropdown control ,now my problem is that when i submit a form it will work fine but it does not insert the second usercontrol dropdown selected value and its enable to find the value .what should i do please see the below code.
UserControls_CategoryDropdown uc = (UserControls_CategoryDropdown)LoadControl("~/UserControls/CategoryDropdown.ascx");

DropDownList ddl = uc.FindControl("ddlcategory") as DropDownList;

UserControls_CategoryDropdown is second usercontrol which contain dropdownlist control and i want to get the value of selected value from this dropdownlist .
Thanks
Posted

1 solution

First solution:

Just expose a public property in UserControls_CategoryDropdown user control and return dropdown list via this property instead of finding the control.

Second Solution: All server controls converted in the html control during the page rendering on client side so controls id changed to. Therefore when you are finding the control through the id which given in code it will not available on client side.
- For actual id, view the source page the see the actual id generated on client side then try to find through that id.
- If you are using Framework 4.0/3.5 then set attribute "ClientIDMode=Static" of Dropdownlist then you will get your actual id ("ddlcategory") on client side.
 
Share this answer
 

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