Click here to Skip to main content
15,885,916 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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.


C#
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]
Posted
Updated 9-Mar-13 6:42am
v2

1 solution

Try

C#
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();
 
Share this answer
 
v3

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