473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Wizard inside DetailsView bug?

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
3 4049
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Shawn Wildermuth | last post by:
I have a *single* SqlDataSource that loads up a single result set that I show in a GridView. In the GridView, i've added a "Select" button and handling the SelectedItem event. I also have a...
12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
2
by: John R. Lewis | last post by:
I posted this yesterday with a different email address. I am reposting with my fake-address as given to me by Microsoft so that I can be guraranteed a response from a support representative. Sorry...
0
by: ottawa111 | last post by:
Hi, I have a detailsview which has a bit mask field , I am showing each bit with checkbox.I am thinking grid view would be a good choice. I put the gridview in a template.but I don't know how to...
0
by: mike | last post by:
Hi, When I programatically Bind a DataSource to DetailsView it does not fire "ModeChanged" event. This is first time i am trying to use ASP.NET DetailsView control. I have played with some of the...
0
by: Christian Schlemmer | last post by:
hi, in a DetailsView i have a image display. images i want to store in a seperate directory, but it a path is added to Bind update and delete is not working. just Bind makes my...
1
by: gsauns | last post by:
I have a DetailsView inside a ModalPopup (using the AJAX ModalPopupExtender). I would like the user to have the ability to change the DetailsView's mode within the ModalPopup. But whenever I...
1
by: ajrock2000 | last post by:
I am using a DetailsView to display some data. I am basically getting a firstname, and lastname fields from a database (the database cannot be changed, nor the queries), and I must concatenate the ,...
0
by: =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= | last post by:
In VS2008, I have a DetailsView control with a checkboxlist control inside its Edit template. (1) I want the checkboxlist to be dynamic and display only as many checkboxes as a user setting is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.