my webpart should have a lot of questions with answertype dropdownlist. In the settings the questions are configurable with a toolpart. Write and read the settings of one question works. I don´t know how the code works for x-more questions (in which method must I use the redundant code - where and how can I encapsulated the code? Have you a tip for me, or do you know an interessting website? I hope you can understand my problem; else I write more details...
thanks
In Addition the (essential part of) code from the toolpart:
public class FeedbackToolpart : ToolPart
{
Label ques1Lab, ans1Lab, typ1Lab;
DropDownList ddList;
List<Question> outputList;
...
public FeedbackToolpart() : base() { this.Title = "Bewertungseinstellungen"; }
protected override void CreateChildControls()
{
parentWebPart = (Feedbackwebpart)this.ParentToolPane.SelectedWebPart;
...
ddList = new DropDownList();
ddList.ID = "TheCheckBoxList";
ddList.Items.Add("");
ddList.Items.Add("Schieberegler");
ddList.Items.Add("Checkboxen");
ddList.Items.Add("Textbox");
ddList.SelectedIndexChanged += new EventHandler(ddList_SelectedIndexChanged);
ddList.AutoPostBack = true;
ddList.SelectedValue = (parentWebPart.MyValue != null) ? parentWebPart.MyValue[0].answType : "Textbox";
this.Controls.Add(pan);
base.CreateChildControls();
}
protected void ddList_SelectedIndexChanged(object sender, EventArgs e) { ... }
public override void ApplyChanges()
{
parentWebPart = (Feedbackwebpart)this.ParentToolPane.SelectedWebPart;
outputList = new List<Question>();
outputList.Add(new Question(texQuestion.Text, texAnswers.Text, ddList.SelectedValue));
parentWebPart.MyValue = outputList;
}
}