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 to drasticly reduce the number of lines of code I need to write.
But when I combine those two controls, databinding breaks. Please see the
example below. The database in this example is a simple access database with
a single table My real life example is way to complicated to describe here,
but this simple case reproduces the problem.
If you run through the wizard, clicking Finish causes a record to be
inserted with null values in all the fields. What I don't show here, is if
you strip out the wizard control, everything works fine.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<script runat="server">
protected void Wizard1_FinishB uttonClick(obje ct sender,
WizardNavigatio nEventArgs e)
{
FormView1.Inser tItem(true);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AccessData Source ID="AccessDataS ource1" runat="server"
DataFile="~/App_Data/db1.mdb"
InsertCommand=" INSERT INTO [Thing] ([Step1Data], [Step2Data], [Step3Data],
[Step4Data]) VALUES (?, ?, ?, ?)"
SelectCommand=" SELECT * FROM [Thing]">
<InsertParamete rs>
<asp:Paramete r Name="Step1Data " Type="String" />
<asp:Paramete r Name="Step2Data " Type="String" />
<asp:Paramete r Name="Step3Data " Type="String" />
<asp:Paramete r Name="Step4Data " Type="String" />
</InsertParameter s>
</asp:AccessDataS ource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateCol umns="False"
DataKeyNames="T hingID"
DataSourceID="A ccessDataSource 1">
<Columns>
<asp:BoundFie ld DataField="Thin gID" HeaderText="Thi ngID"
InsertVisible=" False" ReadOnly="True"
SortExpression= "ThingID" />
<asp:BoundFie ld DataField="Step 1Data" HeaderText="Ste p1Data"
SortExpression= "Step1Data" />
<asp:BoundFie ld DataField="Step 2Data" HeaderText="Ste p2Data"
SortExpression= "Step2Data" />
<asp:BoundFie ld DataField="Step 3Data" HeaderText="Ste p3Data"
SortExpression= "Step3Data" />
<asp:BoundFie ld DataField="Step 4Data" HeaderText="Ste p4Data"
SortExpression= "Step4Data" />
</Columns>
</asp:GridView>
<asp:FormView ID="FormView1" runat="server" DataSourceID="A ccessDataSource 1"
DataKeyNames="T hingID" DefaultMode="In sert">
<InsertItemTemp late>
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex ="0"
OnFinishButtonC lick="Wizard1_F inishButtonClic k">
<WizardSteps>
<asp:WizardSt ep ID="WizardStep1 " runat="server" Title="Step 1">Step1Data :
<asp:TextBox ID="Step1DataTe xtBox" runat="server" Text='<%#
Bind("Step1Data ") %>'></asp:TextBox><br />
</asp:WizardStep>
<asp:WizardSt ep ID="WizardStep2 " runat="server" Title="Step 2">Step2Data :
<asp:TextBox ID="Step2DataTe xtBox" runat="server" Text='<%#
Bind("Step2Data ") %>'></asp:TextBox><br />
</asp:WizardStep>
<asp:WizardSt ep ID="WizardStep3 " runat="server" Title="Step 3">Step3Data :
<asp:TextBox ID="Step3DataTe xtBox" runat="server" Text='<%#
Bind("Step3Data ") %>'></asp:TextBox><br />
</asp:WizardStep>
<asp:WizardSt ep ID="WizardStep4 " runat="server" Title="Step 4">Step4Data :
<asp:TextBox ID="Step4DataTe xtBox" runat="server" Text='<%#
Bind("Step4Data ") %>'></asp:TextBox><br />
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</InsertItemTempl ate>
</asp:FormView>
</div>
</form>
</body>
</html>