SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
Solved to add from  dropdownlist,checkboxlist in a textbox multiple

    protected void ButtonAddDataBase_Click(object sender, EventArgs e)
        string dropDownListValue =  DropDownListDataBase.SelectedItem.Value;
         resultValue += " ";

        TextBoxResultDataBaseSkills.Text += Environment.NewLine;
        TextBoxResultDataBaseSkills.Text += dropDownListValue + " - ";

        foreach (ListItem item in CheckBoxListDataBase.Items)
            if (item.Text == "Beginner" && item.Selected)

                TextBoxResultDataBaseSkills.Text += item.Text; 

                if (item.Text == "Medium" && item.Selected)

                    TextBoxResultDataBaseSkills.Text += item.Text;

                    if (item.Text == "Expert" && item.Selected)

                        TextBoxResultDataBaseSkills.Text += item.Text;

share|improve this question
what you actually want to as the way you are using switch statement looks really odd – Muhammad Raja Mar 9 '13 at 17:14
@MuhammadRaja alright what should i use then ? – Batistuta Mar 9 '13 at 17:15
What you are developing ? is it a webpart – Muhammad Raja Mar 9 '13 at 17:26
@MuhammadRaja Yes – Batistuta Mar 9 '13 at 17:29
which version of SharePoint you are developing it for – Muhammad Raja Mar 9 '13 at 18:04

You should be doing something like this,

 protected void ButtonAddDataBase_Click(object sender, EventArgs e)
     string textBoxValue = string.empty;

     //check if drop down value isn't null if it isn't then add it to text box
          textBoxValue  = DropDownListDataBase.SelectedItem.Value.ToString();

     //now check which checkbox is checked

     if(chkboxBeginner.Checked == true)
        textBoxValue  += ": " + chkboxBeginner.Text; // or maybe check .title

     else if(chkboxMedium.Checked == true)
        textBoxValue  += ": " + chkboxMedium.Text;

     else if(chkboxExpert.Checked == true)
        textBoxValue  += ": " + chkboxExpert.Text;

     //at end set text of your textbox
     TextBoxResultDataBaseSkills.Text = textBoxValue;

I hand coded this code so there might be some exceptions you should be able to fix, you should also use jQuery to add validations so that only one checkbox is selected all the times and forcing user to select some value in dropdownlist.

you will have to set checkbox's ids and text values in markup if its happening in otherwise behind code in createchildcontrols methond.

You might have to add your controls within a Update Panel so that it won't post back and loose selected values.

Here's a question stating how to use update panel in webpart if you don't know already,

UpdatePanel with SharePoint 2010 web part

share|improve this answer
Alright , were could i find the jquery to add validations? – Batistuta Mar 9 '13 at 17:57
@Martin here's an example… but did you ever worked with ajax or update panels as I think they will be easier for you to work with. – Muhammad Raja Mar 9 '13 at 18:02
i have not worked with ajax but i have worked with Update panels "the tools that in VS" – Batistuta Mar 9 '13 at 18:08
@Muhammed Raja i have updated in the top the code that i have written i have putted all the code in a update panel – Batistuta Mar 9 '13 at 18:08
@Muhammed Raja i will also upload a image in the top, what my problem is now, i have putted al the code in a "Update Panel" – Batistuta Mar 9 '13 at 18:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.