My current solution is shown below. I setup a Hashtable which stores the ID
of the radiobutton list (which contains the Group# and Question #) and the
SelectedValue. When the event fire for a radiobutton list, it checks to see
if that ID/Value combo exists in the Hashtable. If the exact ID/Value
combination exists, it returns from the event handler. Otherwise it
adds/replaces the ID/Value.
The one thing noticed is that the radiobuttonlists retain their values
between postbacks, which is what I want. I do not want then to revert back
to their original values. I do, however want the user to be able to go back
and change them, which is going to make the conditional display of
subsequent questions interesting. (If you go back and kill your
grandfather, you no longer exist!) This is a user requirement, so that is
what I need to do.
Anyway, thanks for your help. Any more creative solutions would be
appreciated.
//----------------------------------------------------------------
// Generic Event for Question RadioButtonList
//----------------------------------------------------------------
private void rblQuestion_SelectedIndexChanged(object sender,
System.EventArgs e)
{
htQuestionAnswer = Session["htQuestionAnswer"] as Hashtable;
RadioButtonList rbl;
rbl = (RadioButtonList) sender;
if (htQuestionAnswer.ContainsKey(rbl.ID))
{
if (htQuestionAnswer[rbl.ID].ToString() == rbl.SelectedValue)
{
// Ignore dup event
return;
}
else
{
// replace value, save Hashtable
htQuestionAnswer[rbl.ID] = rbl.SelectedValue;
Session["htQuestionAnswer"] = htQuestionAnswer;
}
}
else
{
// add value, save Hashtable
htQuestionAnswer.Add(rbl.ID,rbl.SelectedValue);
Session["htQuestionAnswer"] = htQuestionAnswer;
}
// Logic goes here
}
<sa*************@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
It isn't weird. Both radio button lists are have changed values from
the time they were built. When you click one you cause the whole
pageto be rebuilt, and that's why the change value event fires for
both. Thats why I think if you put the question 1 answer back to its
default value and then click question 2 you will only get the question
2 event. You might try this just for experimentation.
I forgot that you have AutoPostBack set to true for these controls so
when you click them a postback happens automatically. I understand
that you just want the new question event to fire. How to solve?
Hmmmmm... Can you use different event handlers? You could also detect
the GroupName property of the individual items in the RadioButtonList
to see which question has been clicked. I know you must be giving them
unique values on the form or they wouldn't function as grouped radio
buttons. So your event handler would look like
if(radioButton.item[0].GroupName == "question1") {... do stuff }
Anyway, if anyone else has ideas?