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.
This example shows a Wizard control that is bound to an AccessDataSource control.
- Declare an <
asp:wizard
> element on the page. For syntax, see Wizard Control Syntax.
- Specify the control’s DataSourceID property.
- Optionally set the control’s base properties.
<asp:wizard id="plansView" runat="server"
datasourceid="plans"
width="90%"
cellpadding=5>
- Within the Wizard declaration, declare an <ItemTemplate> element.
- 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>
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.
Introduction to the Wizard Control