Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Extendeed the CreateUserWizard controll by adding a dropdown controll in it.
I have loaded dropdown once in a page load as

C#
if(!page.ispostback())
{ ((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ddlTestType")).Items.Clear();
        ((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ddlTestType")).DataSource = TestTypeSectionManager.getTestTypes();
        ((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ddlTestType")).DataBind();
}


Problem is that when I click the Create User Button and get its selected vale it always return value Empty value.But other dropdowns that are not bind from DB gives correct selected values.
I get selected value as
C#
regUser.TestType = ((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ddlTestType")).SelectedValue.ToString();


Any Help Please.

[edit]"Treat my content as plain text..." option disabled - OriginalGriff[/edit]
Posted
Updated 9-Oct-11 21:15pm
v3

1 solution

C#
if(!page.ispostback())
{ ((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ddlTestType")).Items.Clear();
        ((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl
("ddlTestType")).DataSource = TestTypeSectionManager.getTestTypes();
Try this.
<pre>((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl(&quot;ddlTestType&quot;)).datatextfield = "TestTypesName"

((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl(&quot;ddlTestType&quot;)).datavaluefield = "TestTypesId"


((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ddlTestType")).DataBind();
}
 
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