J
Joanne
Hi,
I have an "interesting" problem with UserControls in a datagrid and I'm
desperate for your help as I work alone and have no-one else to ask. It
is quite complicated but I'll try to keep it to a simple example ...
FormQuestionAnswer.ascx
-----------------------
I have a user Control that displays a question (from a questionnaire)
and its answer (as previously selected by a user). The question has a
list of possible answers in a CheckBoxList control. There is also an
"Other" option allowing the user to specify an answer as text. Note:
this is supposed to be a read-only control simply for display purposes,
I am not requiring any user input here.
QuestionnaireAnswerList.ascx
----------------------------
The parent UserControl contains a datagrid based on a particular
questionnaire with answers given by a particular user. Each row in the
datagrid displays an instance of the FormQuestionAnswer.ascx
UserControl, one for each question in the questionnaire.
When I first load the page the answers are all selected correctly. Any
text answers are displayed in labels.
However if, for any reason, the page is posted back (e.g. the
questionnaire is changed or the user is changed) then the list controls
no longer display any selections. Any text answers do still come
through as labels. Please note: this is NOT a ViewState issue as I am
loading up new controls afresh with new answers each time and the
selections are made according to data from my database.
I have been through the code a hundred times and traced the stack. Each
time the followng happens: the datagrid is bound, the
FormQuestionAnswer controls are created, the list controls are
databound and then last of all the selections are made. Nothing happens
to the controls after the selections are made (I was looking for a
subsequent DataBind() that would account for the selections being lost
but it doesn't happen).
I cannot find any significant difference in the stack trace when the
page is posted back which would account for this problem.
Does anyone have any ideas as to why this might be happening? Any
insight much appreciated.
Thanks in advance.
Joanne
I have an "interesting" problem with UserControls in a datagrid and I'm
desperate for your help as I work alone and have no-one else to ask. It
is quite complicated but I'll try to keep it to a simple example ...
FormQuestionAnswer.ascx
-----------------------
I have a user Control that displays a question (from a questionnaire)
and its answer (as previously selected by a user). The question has a
list of possible answers in a CheckBoxList control. There is also an
"Other" option allowing the user to specify an answer as text. Note:
this is supposed to be a read-only control simply for display purposes,
I am not requiring any user input here.
QuestionnaireAnswerList.ascx
----------------------------
The parent UserControl contains a datagrid based on a particular
questionnaire with answers given by a particular user. Each row in the
datagrid displays an instance of the FormQuestionAnswer.ascx
UserControl, one for each question in the questionnaire.
When I first load the page the answers are all selected correctly. Any
text answers are displayed in labels.
However if, for any reason, the page is posted back (e.g. the
questionnaire is changed or the user is changed) then the list controls
no longer display any selections. Any text answers do still come
through as labels. Please note: this is NOT a ViewState issue as I am
loading up new controls afresh with new answers each time and the
selections are made according to data from my database.
I have been through the code a hundred times and traced the stack. Each
time the followng happens: the datagrid is bound, the
FormQuestionAnswer controls are created, the list controls are
databound and then last of all the selections are made. Nothing happens
to the controls after the selections are made (I was looking for a
subsequent DataBind() that would account for the selections being lost
but it doesn't happen).
I cannot find any significant difference in the stack trace when the
page is posted back which would account for this problem.
Does anyone have any ideas as to why this might be happening? Any
insight much appreciated.
Thanks in advance.
Joanne