PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

databind asp.net wizard control

 
 
MarcG
Guest
Posts: n/a
 
      6th Mar 2008
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
 
Reply With Quote
 
 
 
 
Steven Cheng
Guest
Posts: n/a
 
      7th Mar 2008
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 Removed).

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

http://msdn.microsoft.com/subscripti...ult.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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
>From: =?Utf-8?B?TWFyY0c=?= <(E-Mail Removed)>
>Subject: databind asp.net wizard control
>Date: Thu, 6 Mar 2008 07:53:02 -0800


>
>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
>


 
Reply With Quote
 
MarcG
Guest
Posts: n/a
 
      7th Mar 2008
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

 
Reply With Quote
 
Steven Cheng
Guest
Posts: n/a
 
      10th Mar 2008
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 Removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?TWFyY0c=?= <(E-Mail Removed)>
>References: <2DD78A00-7CC2-4433-AFC5-(E-Mail Removed)>

<6X0Fqa$(E-Mail Removed)>
>Subject: RE: databind asp.net wizard control
>Date: Fri, 7 Mar 2008 00:39:01 -0800


>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
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When does a Bound Control DataBind? Jonathan Wood Microsoft ASP .NET 6 11th May 2008 12:22 AM
Databind to Accordion Control biggerandbetterkahler@googlemail.com Microsoft ASP .NET 0 13th Nov 2006 09:35 AM
How to DataBind droplist control in FormView Control EditItem mode =?Utf-8?B?eXVjaGFuZw==?= Microsoft ASP .NET 0 15th Apr 2006 02:35 AM
How can I databind a gridview to more than one control? needin4mation@gmail.com Microsoft ASP .NET 0 25th Mar 2006 03:36 AM
Databind custom control? phancey@2bytes.co.uk Microsoft Access Forms 1 4th Feb 2005 11:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:04 PM.