C
chrisn
Hi,
(Using ASP.Net 2.0)
I have a wizard control inside a detailsview control. When I attempt
to call the InsertItem method on the DetailsView I get an error
"ObjectDataSource 'ObjectDataSource1' has no values to insert. Check
that the 'values' dictionary contains values."
I have found I can suppress the error by placing a hidden field inside
the DetailsView, but outside the Wizard control. This hidden field
must be bound to the DetailsView dataitem. The only problem with this
is that the two-way databinding is broken.
This behaviour seems very similar to that in bug FDBK27772,
http://lab.msdn.microsoft.com/Produ...edbackID=b104cbc3-8a55-4752-8c11-7e93b1d52077
I was going to submit this to Microsoft, but I thought I'd try here
first.
Thanks,
Chris Needham
Sample code below...
In app_code...
public class Animal
{
public Animal()
{
}
private int id;
public int Id
{
get { return id; }
set { id = value; }
}
private string description;
public string Description
{
get { return description; }
set { description = value; }
}
}
public class AnimalBL
{
public AnimalBL() { }
public void Insert(Animal newAnimal) { }
public Animal Select()
{
return new Animal();
}
}
In the page....
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<form id="form1" runat="server">
<asp:ObjectDataSource ID="ObjectDataSource1"
runat="server"
DataObjectTypeName="Animal"
InsertMethod="Insert"
SelectMethod="Select"
TypeName="AnimalBL">
</asp:ObjectDataSource>
<aspetailsView ID="DetailsView1"
runat="server"
AutoGenerateRows="False"
DataSourceID="ObjectDataSource1"
Height="50px"
Width="125px"
DefaultMode="Insert">
<Fields>
<asp:TemplateField>
<ItemTemplate>
<asp:Wizard ID="Wizard1" runat="server"
OnFinishButtonClick="Wizard1_FinishButtonClick1">
<WizardSteps>
<asp:WizardStep ID="WizardStep1"
runat="server" Title="Step 1">
<asp:Label ID="Label1"
runat="server" Text="Description"></asp:Label>
<asp:TextBox ID="TextBox1"
runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</ItemTemplate>
</asp:TemplateField>
</Fields>
</aspetailsView>
</form>
</body>
</html>
in the code - behind
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Wizard1_FinishButtonClick1(object sender,
WizardNavigationEventArgs e)
{
this.DetailsView1.InsertItem(true);
}
}
(Using ASP.Net 2.0)
I have a wizard control inside a detailsview control. When I attempt
to call the InsertItem method on the DetailsView I get an error
"ObjectDataSource 'ObjectDataSource1' has no values to insert. Check
that the 'values' dictionary contains values."
I have found I can suppress the error by placing a hidden field inside
the DetailsView, but outside the Wizard control. This hidden field
must be bound to the DetailsView dataitem. The only problem with this
is that the two-way databinding is broken.
This behaviour seems very similar to that in bug FDBK27772,
http://lab.msdn.microsoft.com/Produ...edbackID=b104cbc3-8a55-4752-8c11-7e93b1d52077
I was going to submit this to Microsoft, but I thought I'd try here
first.
Thanks,
Chris Needham
Sample code below...
In app_code...
public class Animal
{
public Animal()
{
}
private int id;
public int Id
{
get { return id; }
set { id = value; }
}
private string description;
public string Description
{
get { return description; }
set { description = value; }
}
}
public class AnimalBL
{
public AnimalBL() { }
public void Insert(Animal newAnimal) { }
public Animal Select()
{
return new Animal();
}
}
In the page....
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<form id="form1" runat="server">
<asp:ObjectDataSource ID="ObjectDataSource1"
runat="server"
DataObjectTypeName="Animal"
InsertMethod="Insert"
SelectMethod="Select"
TypeName="AnimalBL">
</asp:ObjectDataSource>
<aspetailsView ID="DetailsView1"
runat="server"
AutoGenerateRows="False"
DataSourceID="ObjectDataSource1"
Height="50px"
Width="125px"
DefaultMode="Insert">
<Fields>
<asp:TemplateField>
<ItemTemplate>
<asp:Wizard ID="Wizard1" runat="server"
OnFinishButtonClick="Wizard1_FinishButtonClick1">
<WizardSteps>
<asp:WizardStep ID="WizardStep1"
runat="server" Title="Step 1">
<asp:Label ID="Label1"
runat="server" Text="Description"></asp:Label>
<asp:TextBox ID="TextBox1"
runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</ItemTemplate>
</asp:TemplateField>
</Fields>
</aspetailsView>
</form>
</body>
</html>
in the code - behind
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Wizard1_FinishButtonClick1(object sender,
WizardNavigationEventArgs e)
{
this.DetailsView1.InsertItem(true);
}
}