databind asp.net wizard control

M

MarcG

I want to use a asp.net wizard control to help the user enter fields for a
single complex record. The idea is for each page to solicit data for a subset
of the fields and at the end do the update.

The wizard has a DataBind method, but I can't find a way to associate the
SqlDataSource on the page with the wizard control itself.

In the aspx I have...

<asp:Wizard ID="surveyDescrWizard" runat="server" Width="800px">
.....
<WizardSteps>
<asp:WizardStep runat="server" Title="Page 2">
Title:
<asp:Literal ID="Literal1" runat="server"
Text="LiteralText"></asp:Literal>
<asp:TextBox ID="TextBox1" runat="server"
BorderStyle="Double" Text='<%# Bind("Title") %>'></asp:TextBox>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ...>
....
</asp:SqlDataSource>

In my page load event I have...
if (!IsPostBack)
{
surveyDescrWizard.DataBind();
}

I get the exception ...
"Databinding methods such as Eval(), XPath(), and Bind() can only be used
in the context of a databound control."

On reflection (so to speak) this makes perfect sense since there is no
property or method that lets you associate the datasource with the wizard
itself.

Since the Wizard control offers a DataBind() method, there must be some way
to do this, but I just can't see it.

Thx
Marc
 
S

Steven Cheng

Hi Marc,

As for the error you encountered, it is because Wizard control is not a
databound control(such as Gridview, FormView or dropdownlist...).
Therefore, Wizard control does not support databinding expression directly
located in its member template. The "DataBind" method you mentioned is
used for simple databind(for Wizard control's own properties) e.g.

=============
<asp:Wizard ID="Wizard1" ... Width='<%# ..... %>' Height='<%#
....%>' >
....
==========

If you do need to use databinding to populate controls in Wizard, I think
you may consider put a databound template control inside Wizard control's
step so as to wrapper other controls that need databinding. How do you
think?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: (e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response

from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take

approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution.

The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump

analysis issues. Issues of this nature are best handled working with a
dedicated Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 
M

MarcG

Steven,

A clear response, thank you. Unfortunately it was more or less what I was
expecting.
If you do need to use databinding to populate controls in Wizard, I think
you may consider put a databound template control inside Wizard control's
step so as to wrapper other controls that need databinding. How do you
think?

You suggested putting a databound control inside the Wizard steps and that
is actually what I was hoping to avoid.

Here's the problem...

Functionally, I want to break up the process of entering the data into steps
since there are too many fields for the user to deal with at one time - the
UI would be much too confusing and cumbersome. So the Wizard is conceptually
a perfect solution.

Programmatically, I don't see a good design pattern. Each step would have to
have its own databound control, eg.., a FormView or DetailView. Each of these
has to be bound to a datasource. However, I can't use a single datasource for
the entire Wizard since, although all FormViews could share the Select
statement, they each have to have their own Update statement since each would
only have its own variables (fields). I think this approach would also mean
that I have to update the record in multiple steps, one for each Wizard step.

I'd like to use the Wizard to collect the data and then do a single Update
when the user clicks "Finish." I know I can do this using unbound input
fields and writing code to collect the data values from the Wizard,
constructing a record and doing the update manually. I was hoping to used the
bound data model.

Marc
 
S

Steven Cheng

Hi Marc,

Yes, putting an additional databound control here is only to make each
wizard step template to able to use the datasource control. That would make
the design not quite elegant. I'm afraid so far the Wizard control can not
quite support databinding with datasource control or event bind fields in
all template with a single datasource control. So far what I can get to
make this work is do all the data/fields collection in our own code and
then call Data Access class(or datasource control ) to programmatically do
the update. I think you may already tried this or thought this to be a
backup plan?

Best regards,

Steven Cheng
Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: (e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?TWFyY0c=?= <[email protected]>
References: <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top