Oct 11, 2013, 2:26 PM
[CLOSED] Read Value from Dynamically Generated Radio Group
I have a dynamically generated form working off of questions in a database. Here's how the radio group/options are generated.
I also tried
if (question.QuestionType.TypeName == "radio"){
ext.RadioGroup RadioGroup = new ext.RadioGroup()
{
ID = "q" + question.FormQuestionID.ToString(),
FieldLabel = question.QuestionText,
LabelAlign = ext.LabelAlign.Top,
MaxWidth = 400,
};
List<QuestionOption> Options = (from o in MyConn.QuestionOption
where question.FormQuestionID == o.FormQuestionId
select o).ToList();
foreach (QuestionOption o in Options)
{
RadioGroup.Items.Add(new ext.Radio()
{
ID= "o" + o.QuestionOptionId.ToString(),
BoxLabel = o.OptionName,
Value = o.QuestionOptionId.ToString(),
MaxWidth = 50,
Padding = 5,
Margin = 5
});
}
MyContainer.Items.Add(RadioGroup);
}
After the form is filled out, in PageLoad I regenerate the form, and then the Click Handler for the Submit Button fires. Here's how I iterate through the response if it's a radio button.if (question.TypeName == "radio")
{
FormAnswer Answer = new FormAnswer{
FormQuestionID = question.FormQuestionID,
Answer = Request["q" + question.FormQuestionID]
};
MyConn.FormAnswer.Add(Answer);
}
For text, textarea, datepicker, and dropdown fields, the responses are captured and saved to the database properly. For the radio buttons, the Request["q" + question.FormQuestionID] is null.I also tried
ext.X.GetCmp<ext.RadioGroup>("q" + question.FormQuestionID).CheckedItems[0].Value.ToString()
and receive an Invalid cast exception on CheckedItems
Last edited by Daniil; Oct 18, 2013 at 4:46 AM.
Reason: [CLOSED]