在下拉列表中显示selecteditem.value,在文本框中显示checkboxlist [英] display selecteditem.value from dropdownlist and checkboxlist in a textbox
问题描述
在下拉列表中选择MS SQL Server并在CheckboxList中选择Beginner时,我希望它在文本框中显示,然后单击添加按钮,结果应该在文本框MS SQL Server中 - 初学者在我的例子中,代码看起来像这样,它只在文本框中显示Beginner,而不是我在下拉列表中选择的值。
protected void ButtonAddDataBase_Click( object sender,EventArgs e)
{
switch (DropDownListDataBase.SelectedItem .Value)
{
case MS SQL Server:
TextBoxResultDataBaseSkills.Text = DropDownListDataBase.SelectedItem.Value;
break ;
}
switch (CheckBoxListDataBase.SelectedItem.Value)
{
case 初学者:
TextBoxResultDataBaseSkills.Text = CheckBoxListDataBase .SelectedItem.Value;
break ;
}
}
这是一个链接图像也是
http://sharepoint.stackexchange.com/questions/61602/display-selecteditem-value-from-dropdownlist-and-checkboxlist-in-a-textbox [ ^ ]
能够点击链接[/编辑]
试试
listBox.SelectedItem.ToString()
如果在ValueMember中没有指定属性,则SelectedValue返回对象的ToString方法的结果。
编辑:
更改:CheckBoxL istDataBase.SelectedItem.Value
进入 - > CheckBoxListDataBase.SelectedItem.ToString();
When selecting "MS SQL Server" in the dropdownlist and also choose "Beginner" in the CheckboxList i want it to be displayed in the Textbox afther clicking the button "Add" So the result should be in the textbox MS SQL Server - Beginner In my case the code looks like this and it only displays "Beginner" in the textbox and not also the value i select in the dropdownlist.
protected void ButtonAddDataBase_Click(object sender, EventArgs e)
{
switch (DropDownListDataBase.SelectedItem.Value)
{
case "MS SQL Server":
TextBoxResultDataBaseSkills.Text = DropDownListDataBase.SelectedItem.Value;
break;
}
switch (CheckBoxListDataBase.SelectedItem.Value)
{
case "Beginner":
TextBoxResultDataBaseSkills.Text = CheckBoxListDataBase.SelectedItem.Value;
break;
}
}
Here is a link with a image also
http://sharepoint.stackexchange.com/questions/61602/display-selecteditem-value-from-dropdownlist-and-checkboxlist-in-a-textbox[^]
[Edit]Made able to click on the link[/Edit]
Try
listBox.SelectedItem.ToString()
If a property isn''t specified in ValueMember then SelectedValue returns the results of the ToString method of the object.
Edit:
Change: CheckBoxListDataBase.SelectedItem.Value
Into -> CheckBoxListDataBase.SelectedItem.ToString();
这篇关于在下拉列表中显示selecteditem.value,在文本框中显示checkboxlist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!