M
Mark Stafford
I am attempting to use a DetailsView control to view some data where
the fields returned by the database are determined at runtime. I
create the TemplateFields on the fly using a class that implements
ITemplate and repopulate the Template properters of TemplateField in
OnInit. And I am DataBinding by getting a DataTable from my db
provider class in Page_Load event. When I databind programmatically in
the Page_Load, the data displays in the ReadOnly mode fine, but when I
click on Edit command button, it does a postback and the data in the
right column (not the headers) disappears and it does not go into Edit
mode or call the EditItemTemplates. It just goes back into ReadOnly
mode. The ModeChanging event is fired but the ModeChanged is not. I
tried using an ObjectDataSource declaritively in the aspx file. Then
it then goes into Edit mode but another issue arises. The fields again
are determined at runtime so I can't hard code the UpdateParameters. I
tried using and Update method that took a DataTable or Hashtable. But
I can't seem to find a way to have it pass me a dynamic data object
when using the ObjectDataSource. If I use a Hashtable, it blows up.
If my update method takes a DataTable, the update method does not get
called nor does the ItemUpdating event get called so that I could
handle it in there. And it gets stuck in Edit mode.
I have a nice welt on my forehead from banging my head against the wall
here. Does anyone have any ideas on how to view/edit data that is
determined runtime? I thought this would have been easy in ASP.NET 2.0
but maybe I am just missing something.
Thanks
Mark
the fields returned by the database are determined at runtime. I
create the TemplateFields on the fly using a class that implements
ITemplate and repopulate the Template properters of TemplateField in
OnInit. And I am DataBinding by getting a DataTable from my db
provider class in Page_Load event. When I databind programmatically in
the Page_Load, the data displays in the ReadOnly mode fine, but when I
click on Edit command button, it does a postback and the data in the
right column (not the headers) disappears and it does not go into Edit
mode or call the EditItemTemplates. It just goes back into ReadOnly
mode. The ModeChanging event is fired but the ModeChanged is not. I
tried using an ObjectDataSource declaritively in the aspx file. Then
it then goes into Edit mode but another issue arises. The fields again
are determined at runtime so I can't hard code the UpdateParameters. I
tried using and Update method that took a DataTable or Hashtable. But
I can't seem to find a way to have it pass me a dynamic data object
when using the ObjectDataSource. If I use a Hashtable, it blows up.
If my update method takes a DataTable, the update method does not get
called nor does the ItemUpdating event get called so that I could
handle it in there. And it gets stuck in Edit mode.
I have a nice welt on my forehead from banging my head against the wall
here. Does anyone have any ideas on how to view/edit data that is
determined runtime? I thought this would have been easy in ASP.NET 2.0
but maybe I am just missing something.
Thanks
Mark