S
Samuel
hi,
I am new to this CompositeDataBoundControl, and I have an issue with loading
viewstate on Postback. The error message is as follows:
"failed to load viewstate. The control tree into which viewstate is being
loaded must match the control tree that was used to save viewstate during the
previous request. For example, when adding controls dynamically, the
controls added during a post-back must match the type and position of the
controls added during the initial request."
What my control does is it needs to build both its structure (textbox,
dropdownlist, etc) and their respective data based on values from the db.
It is used to present a set of custom registration fields where user can
design what fields they want to display on the form, and each field can be
represented in either textbox, dropdownlist, radiobuttonlist, or
checkboxlist. The preferences are saved in the database.
So, the control interacts with 2 sets of data, one for its structure and
default values (in the case of listcontrol), and another for the user's
selection when users want to edit the data afterward (not needed for
registration).
What I am doing is I am creating both structure (the control will get the
data by itself without any input) and binding the data (from
control.datasource) in the overloaded CreateChildControls function:
CreateChildControls(dataSource As IEnumerable, dataBinding As Boolean) As
Integer
When the control is in Editing mode (both sets of data available), it works
fine because I have to call databind. If it is in Registration mode (no user
data, but structure data only) or Postback (where databind is not called),
the control is entirely empty (no structure at all) and errored because
without calling databind the CreateChildControls function is not fired.
Am I doing something wrong, or should I be looking to inherit from a
different class than CompositeDataBoundControl?
Thanks in advance!
I am new to this CompositeDataBoundControl, and I have an issue with loading
viewstate on Postback. The error message is as follows:
"failed to load viewstate. The control tree into which viewstate is being
loaded must match the control tree that was used to save viewstate during the
previous request. For example, when adding controls dynamically, the
controls added during a post-back must match the type and position of the
controls added during the initial request."
What my control does is it needs to build both its structure (textbox,
dropdownlist, etc) and their respective data based on values from the db.
It is used to present a set of custom registration fields where user can
design what fields they want to display on the form, and each field can be
represented in either textbox, dropdownlist, radiobuttonlist, or
checkboxlist. The preferences are saved in the database.
So, the control interacts with 2 sets of data, one for its structure and
default values (in the case of listcontrol), and another for the user's
selection when users want to edit the data afterward (not needed for
registration).
What I am doing is I am creating both structure (the control will get the
data by itself without any input) and binding the data (from
control.datasource) in the overloaded CreateChildControls function:
CreateChildControls(dataSource As IEnumerable, dataBinding As Boolean) As
Integer
When the control is in Editing mode (both sets of data available), it works
fine because I have to call databind. If it is in Registration mode (no user
data, but structure data only) or Postback (where databind is not called),
the control is entirely empty (no structure at all) and errored because
without calling databind the CreateChildControls function is not fired.
Am I doing something wrong, or should I be looking to inherit from a
different class than CompositeDataBoundControl?
Thanks in advance!