asp.net.ph

Skip Navigation Links

Adding Wizard Controls to a Web Forms Page

Controls You Can Use on Web Forms   ASP.NET Standard Controls   Wizard Control


Essentially, to create a working Wizard control, you need to add the control to the page and bind the control to a data source.

The below procedures show the minimum steps needed to display data in a Wizard control.

To add a Wizard control to a Web Forms page

This example shows a Wizard control that is bound to an AccessDataSource control.

  1. Declare an <asp:wizard> element on the page. For syntax, see Wizard Control Syntax.
  2. Specify the control’s DataSourceID property.
  3. Optionally set the control’s base properties.
    <asp:wizard id="plansView" runat="server"
       datasourceid="plans"
       width="90%"
       cellpadding=5>
  4. Within the Wizard declaration, declare an <ItemTemplate> element.
  5. Within the ItemTemplate, define the HTML or server controls that will contain each field you intend to display.

    To display the value of a field in an item template, use DataBinding Expression Syntax.

    <itemtemplate>
       <div class="header">
          <h3 style="color:maroon"><%# Eval ( "Model" ) %></h3>
       </div>
       <br>
       ...
       <p>National Average Cost to Build: <br>
       <b style="color:maroon"><%# Eval ( "Cost", "{0:c}" ) %></b>
       ...
    </itemtemplate>
Wizard Example Details Page
Run Sample | View Source

NOTE: The ItemTemplate must contain at least one HTML element or server control that binds to a field from the data source; otherwise the Wizard has nothing to render.

The DataSource property of a Wizard can also be set programmatically, just like any Web server control property. Below shows an example of binding a data source to a Wizard in code.

<script language="C#" runat="server">
   protected void Page_Load ( object src, EventArgs e ) {
      string query = "SELECT ProductType, ProductCode, ... FROM Products";
      productWizard.DataSource = fetchReader ( query, "dbtutor" );
      productWizard.DataBind ( );
   }
</script>

The above examples apply several concepts and methods that are described elsewhere in this workshop. For particulars, see ADO.NET Primer, Introduction to Data Binding in Web Forms, Web Forms Server Controls Templates.

See Also

Introduction to the Wizard Control



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note