下拉选择值问题 [英] Drop down Selected Value Problem
问题描述
我通过在其中添加一个下拉控件来扩展了CreateUserWizard控件.
我已经在页面加载一次中加载了下拉菜单,如下所示:
I have Extendeed the CreateUserWizard controll by adding a dropdown controll in it.
I have loaded dropdown once in a page load as
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
regUser.TestType = ((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ddlTestType")).SelectedValue.ToString();
请提供任何帮助.
[edit]将我的内容视为纯文本..."选项已禁用-OriginalGriff [/edit]
Any Help Please.
[edit]"Treat my content as plain text..." option disabled - OriginalGriff[/edit]
推荐答案
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("ddlTestType")).datatextfield = "TestTypesName"
((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ddlTestType")).datavaluefield = "TestTypesId"
(((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ddlTestType")).DataBind();
}
((DropDownList)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("ddlTestType")).DataBind();
}
这篇关于下拉选择值问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!