By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,854 Members | 1,912 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,854 IT Pros & Developers. It's quick & easy.

Wizard inside DetailsView bug?

P: n/a
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/Produc...1-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>

<asp:DetailsView 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>
</asp:DetailsView>
</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);
}
}

Mar 30 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Are you sure it is not a scoping thing? Does the wizard control have it's
own scope so the SQL datasource can't see the bound control textbox within
the wizard. This is much the same as you can bind a drop down list in a
template field to an SQLdatasource but you can't use the value of that drop
down as a parameter for an SQL datasource unless that SQLdatasource is within
the TemplateField.

You could get round this by simulating the databinding funtionality by using
the ItemUpdating event handler of the detailsview control and doing something
like

Wizard MyWizard = ((DetailsView)sender).FindControl("Wizard1");
TextBox MyTextBox = (TextBox)MyWizard.FindControl("TextBox1");
e.NewValues = TextBox.Text.ToString();

"ch****@nildram.co.uk" wrote:
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/Produc...1-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>

<asp:DetailsView 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>
</asp:DetailsView>
</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);
}
}

Mar 30 '06 #2

P: n/a
Well Microsoft reckoned the exact same behaviour with a MultiView
inside a FormView was a bug in their article on bug id: FDBK27772.
http://lab.msdn.microsoft.com/Produc...1-7e93b1d52077

This looks very similar.

I have used the same workaround that you suggest to simulate the
databinding by using code, however, I would like to get the databinding
to work, as it's rather cool.

Thanks,
Chris

Mar 30 '06 #3

P: n/a
Perhaps it is a bug, it depends whether the wizard control is a "naming
container" however i think it is probably the scoping issue i mentioned
because that bug report is from the time when ASP.net 2.0 was still in beta
and they say that the issue is fixed. Using the two way databinding isn't
always possible for example if you have two drop down lists with the items in
the second dependent on the selectedvalue in the first there is no way to use
<%#bind("somefield")%> and you have to do it the way i sugested.
"ch****@nildram.co.uk" wrote:
Well Microsoft reckoned the exact same behaviour with a MultiView
inside a FormView was a bug in their article on bug id: FDBK27772.
http://lab.msdn.microsoft.com/Produc...1-7e93b1d52077

This looks very similar.

I have used the same workaround that you suggest to simulate the
databinding by using code, however, I would like to get the databinding
to work, as it's rather cool.

Thanks,
Chris

Mar 30 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.