K
Kbalz
Having a hell of a time with this..
I have a user control. The control is a serach interface for my
database, and each user can customize which fields to search by, and
which return in the results. This information is stored in SQL Server.
Based on that information, I dynamically add text boxes and labels as
the user loads the user control. When the search is performed, I
dynamically add Columns to my gridview based on the SQL Server
information. The grid view also has a command field "open", so when
clicked the userControl sends some information to the parent page (via
eventhandler).
This usercontrol can be dropped into any page.. Everything is working
with the user control. The parent page works with the eventhandler.
Within the usercontrol's codebehind, I had to add an override to the
OnInit method, since I'm using dynamic controls.. I did this as many
sites advised, to prevent losing the dynamic controls and their values
when the control performs a postback.
The problem occurs when the parent page performs a post back.. The
text boxes in the userControl still render, and keep their values..
but the gridview seems to lose its DataSource, and therefore returns
no rows. Note that the parent page is not doing any tricks with
viewstate, or oninit overrides.. I've tried a few things, but can NOT
get the gridview to retain its DataSource..
I think today I'm going to write up a watered down version that still
shows the problem with lots of code for someone to help me test with..
Does anyone have any ideas off the top of their head that I can try?
I have a user control. The control is a serach interface for my
database, and each user can customize which fields to search by, and
which return in the results. This information is stored in SQL Server.
Based on that information, I dynamically add text boxes and labels as
the user loads the user control. When the search is performed, I
dynamically add Columns to my gridview based on the SQL Server
information. The grid view also has a command field "open", so when
clicked the userControl sends some information to the parent page (via
eventhandler).
This usercontrol can be dropped into any page.. Everything is working
with the user control. The parent page works with the eventhandler.
Within the usercontrol's codebehind, I had to add an override to the
OnInit method, since I'm using dynamic controls.. I did this as many
sites advised, to prevent losing the dynamic controls and their values
when the control performs a postback.
The problem occurs when the parent page performs a post back.. The
text boxes in the userControl still render, and keep their values..
but the gridview seems to lose its DataSource, and therefore returns
no rows. Note that the parent page is not doing any tricks with
viewstate, or oninit overrides.. I've tried a few things, but can NOT
get the gridview to retain its DataSource..
I think today I'm going to write up a watered down version that still
shows the problem with lots of code for someone to help me test with..
Does anyone have any ideas off the top of their head that I can try?