473,834 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
"ObjectDataSour ce 'ObjectDataSour ce1' 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="Defau lt.aspx.cs" Inherits="_Defa ult" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<form id="form1" runat="server">
<asp:ObjectData Source ID="ObjectDataS ource1"
runat="server"
DataObjectTypeN ame="Animal"
InsertMethod="I nsert"
SelectMethod="S elect"
TypeName="Anima lBL">
</asp:ObjectDataS ource>

<asp:DetailsVie w ID="DetailsView 1"
runat="server"
AutoGenerateRow s="False"
DataSourceID="O bjectDataSource 1"
Height="50px"
Width="125px"
DefaultMode="In sert">
<Fields>
<asp:TemplateFi eld>
<ItemTemplate >
<asp:Wizard ID="Wizard1" runat="server"
OnFinishButtonC lick="Wizard1_F inishButtonClic k1">
<WizardSteps>
<asp:WizardSt ep ID="WizardStep1 "
runat="server" Title="Step 1">
<asp:Label ID="Label1"
runat="server" Text="Descripti on"></asp:Label>
<asp:TextBox ID="TextBox1"
runat="server" Text='<%# Bind("Descripti on") %>'></asp:TextBox>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</ItemTemplate>
</asp:TemplateFie ld>
</Fields>
</asp:DetailsView >
</form>
</body>
</html>

in the code - behind
using System.Web.UI.W ebControls;

public partial class _Default : System.Web.UI.P age
{
protected void Wizard1_FinishB uttonClick1(obj ect sender,
WizardNavigatio nEventArgs e)
{
this.DetailsVie w1.InsertItem(t rue);
}
}

Mar 30 '06 #1
3 4075
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)s ender).FindCont rol("Wizard1");
TextBox MyTextBox = (TextBox)MyWiza rd.FindControl( "TextBox1") ;
e.NewValues = TextBox.Text.To String();

"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
"ObjectDataSour ce 'ObjectDataSour ce1' 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="Defau lt.aspx.cs" Inherits="_Defa ult" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<form id="form1" runat="server">
<asp:ObjectData Source ID="ObjectDataS ource1"
runat="server"
DataObjectTypeN ame="Animal"
InsertMethod="I nsert"
SelectMethod="S elect"
TypeName="Anima lBL">
</asp:ObjectDataS ource>

<asp:DetailsVie w ID="DetailsView 1"
runat="server"
AutoGenerateRow s="False"
DataSourceID="O bjectDataSource 1"
Height="50px"
Width="125px"
DefaultMode="In sert">
<Fields>
<asp:TemplateFi eld>
<ItemTemplate >
<asp:Wizard ID="Wizard1" runat="server"
OnFinishButtonC lick="Wizard1_F inishButtonClic k1">
<WizardSteps>
<asp:WizardSt ep ID="WizardStep1 "
runat="server" Title="Step 1">
<asp:Label ID="Label1"
runat="server" Text="Descripti on"></asp:Label>
<asp:TextBox ID="TextBox1"
runat="server" Text='<%# Bind("Descripti on") %>'></asp:TextBox>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</ItemTemplate>
</asp:TemplateFie ld>
</Fields>
</asp:DetailsView >
</form>
</body>
</html>

in the code - behind
using System.Web.UI.W ebControls;

public partial class _Default : System.Web.UI.P age
{
protected void Wizard1_FinishB uttonClick1(obj ect sender,
WizardNavigatio nEventArgs e)
{
this.DetailsVie w1.InsertItem(t rue);
}
}

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("somefi eld")%> 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
10074
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 DetailsView (though FormView has this same issue) where I want to be able to set the current item to bind to from the DataSource. All the examples I've seen use two data sources and on every *select* they do another round-trip to the Database (which...
12
8709
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 update after making changes, but I don't want that update button. How can I get the updated object when the user presses one of my other action buttons?
2
4273
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 for the repost. I'd like to make use of the asp:Wizard control to present a step-by-step guided experience for my user to fill out a complicated data-entry form. I'd like to make use of two-way databinding provided by the asp:FormView control...
0
1823
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 gather child gridview data once I click update or insert in detailsview.HELP please
0
2557
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 sample provided by Microsoft and other comminity sites. Most of the samples were using Databinding using a DesignTime "SqlDataSource" Control and assigning its ID to DataSourceID property of DetailsView. However, in all of my application we DO...
0
2893
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 DetailsView updateable, but scripts and images would be nice to be seperated.
1
7198
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 click the button to change the mode, the ModalPopup closes itself. The NEXT time I open the ModalPopup, the mode has been changed. So the mode is changing... my problem is that I need the ModalPopup to stay visible. Also, the DetailsView is inside...
1
2186
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 , . I want to incorporate this into a detailsview like so... <asp:TemplateField HeaderText="Name:"> <ItemTemplate> <%#Eval("firstname")%>, <%#Eval("lastname")%> </ItemTemplate> </asp:TemplateField> ...
0
2217
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 configured. How? (2) Also the column that should depict the checkboxlist selections, is a simple character column in SSE2005, in the form of a comma-delimited string (e.g. 1,5,7,12,23). When the DetailsView is loaded, I want each of the...
0
9799
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9646
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10793
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10548
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10219
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7758
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6954
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3081
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.