G
Guest
Hi,
I am a newbie to ASP.NET 2.0. This is driving me nuts! I think I might have
a fundamental misunderstanding of how this all works!
I am using a DetailsView which is populated dynaically at runtime:
table = DataTable from Dataset passed back from Data Access Layer
DV1 = DetailsView
foreach (DataColumn col in table.Columns)
{
TemplateField TF = new TemplateField();
TF.HeaderText = col.ColumnName.ToString();
if (col.ColumnName == "ID")
{
TF.ItemTemplate = new
DetalsViewTemplate(ListItemType.Item, col.ColumnName);
DV1.Fields.Add(TF);
}
else
{
switch
(table.Rows[0][col.ColumnName].GetType().ToString())
{
case "System.String":
TF.ItemTemplate = new
DetalsViewTemplate(ListItemType.EditItem, col.ColumnName);
break;
case "System.Int32":
TF.ItemTemplate = new
DetalsViewTemplate(ListItemType.EditItem, col.ColumnName);
break;
case "System.Boolean":
TF.ItemTemplate = new
CheckBoxTemplate(col.ColumnName);
break;
case "System.DateTime":
TF.ItemTemplate = new
DateTimeTemplate(col.ColumnName);
break;
}
DV1.Fields.Add(TF);
}
}
I also have a custom "Save" button which fires the DV1.UpdateItem event.
In the event handler I try to access the e.NewValues collection to pass back
to the DAL to update the table.
My problem is that the NewEvents, OldEvents and Keys collections are all
empty. So Ihave been trying to access the DetailsView Fields collection to
get at the new values entered by the user.
Can anybody tell me how to get at those new values please?
Many thanks
Mike
I am a newbie to ASP.NET 2.0. This is driving me nuts! I think I might have
a fundamental misunderstanding of how this all works!
I am using a DetailsView which is populated dynaically at runtime:
table = DataTable from Dataset passed back from Data Access Layer
DV1 = DetailsView
foreach (DataColumn col in table.Columns)
{
TemplateField TF = new TemplateField();
TF.HeaderText = col.ColumnName.ToString();
if (col.ColumnName == "ID")
{
TF.ItemTemplate = new
DetalsViewTemplate(ListItemType.Item, col.ColumnName);
DV1.Fields.Add(TF);
}
else
{
switch
(table.Rows[0][col.ColumnName].GetType().ToString())
{
case "System.String":
TF.ItemTemplate = new
DetalsViewTemplate(ListItemType.EditItem, col.ColumnName);
break;
case "System.Int32":
TF.ItemTemplate = new
DetalsViewTemplate(ListItemType.EditItem, col.ColumnName);
break;
case "System.Boolean":
TF.ItemTemplate = new
CheckBoxTemplate(col.ColumnName);
break;
case "System.DateTime":
TF.ItemTemplate = new
DateTimeTemplate(col.ColumnName);
break;
}
DV1.Fields.Add(TF);
}
}
I also have a custom "Save" button which fires the DV1.UpdateItem event.
In the event handler I try to access the e.NewValues collection to pass back
to the DAL to update the table.
My problem is that the NewEvents, OldEvents and Keys collections are all
empty. So Ihave been trying to access the DetailsView Fields collection to
get at the new values entered by the user.
Can anybody tell me how to get at those new values please?
Many thanks
Mike