ASP.NET Super Form - Cascading ComboBox Field

Order ID11077
Ship Name
Ship Country
Ship City
Update
 
Cancel
12345678910...
Use the TemplateField class to gain full control over the layout of the field.
A TemplateField allows developers to specify different templates for view / add / edit modes.

This example showcases the use of two TemplateField objects - one for the "Ship Country" field and one for the "Ship City" field. Using the TemplateField class we can use ComboBox controls to edit the data from these fields. The two ComboBoxes are linked in cascade - when the selection changes in the "Ship Country" ComboBox, the "Ship City" ComboBox is populated with the cities located in the selected country.


For the source code please check the "aspnet_templates_combobox_cascading.aspx" sample from the SuperForm folder in the Suite.
ASP.NET
<obout:SuperForm ID="SuperForm1"
     runat="server"
     DataSourceID="SqlDataSource1"
     AutoGenerateRows="false">
    <Fields>
        <obout:TemplateField HeaderText="Ship Country">
            <ItemTemplate>
                <%# Eval("ShipCountry") %>
            </ItemTemplate>
            <EditItemTemplate>
                <obout:ComboBox runat="server" ID="ComboBox1" DataSourceID="SqlDataSource2"
                 OnSelectedIndexChanged="ShipCountry_SelectedIndexChanged" AutoPostBack="true"
                 DataValueField="ShipCountry" DataTextField="ShipCountry"
                SelectedValue='<%# Eval("ShipCountry") %>'>
            </EditItemTemplate>
        </obout:TemplateField>
        <obout:TemplateField HeaderText="Ship City">
            <ItemTemplate>
                <%# Eval("ShipCity") %>
            </ItemTemplate>
            <EditItemTemplate>
                <obout:ComboBox runat="server" ID="ComboBox1" DataSourceID="SqlDataSource3"
                 AppendDataBoundItems="false" >
            </EditItemTemplate>
        </obout:TemplateField>
    </Fields>
</obout:SuperForm>
C#
protected void ShipCountry_SelectedIndexChanged(object sender, ComboBoxItemEventArgs e)
{
    SqlDataSource3.SelectParameters[0].DefaultValue = e.Item.Value;
}
VB
Sub ShipCountry_SelectedIndexChanged(ByVal sender As Object, ByVal e As ComboBoxItemEventArgs)

    SqlDataSource3.SelectParameters(0).DefaultValue = e.Item.Value
    
End Sub

"Let me start by saying I love your products, they are by far the best I've used."

T. Bradley
Hansons

Random testimonial   All testimonials

obout.com 
obout.com Home 
News 
Super Form Home   
Super Form Home 
Examples - 64
First Look - 2 
Quick Setup 
Checkout 
Appearance - 3 
Live Styles 
Live Styles for DateFields New 
Auto Format 
Fields - 10 
Auto Generate Fields 
BoundField 
CheckBoxField 
CommandField 
DateField 
DateField with Time New 
DropDownListField 
MultiLineField 
Password Field New 
TemplateField 
Add / Edit / Delete - 7 
Auto Generate Command Buttons 
Customize Command Buttons 
Request User Confirmation 
Add-Only Form 
Edit-Only Form New 
Default Values for Add New 
Save using Stored Procedures New 
Layout - 7 
Vertical / Horizontal Direction 
Field Sets 
Field Sets with Column Span 
Field Sets with Tabs New 
Multi-Step Wizard New 
Multi-Step Survey New 
Width 
Master / Detail - 4 
Master Grid 
Master ComboBox 
Master ListBox 
Add / Edit in Separate Page 
Templates - 11 
ComboBox Field 
On-Demand ComboBox Field New 
Cascading ComboBox Field 
MultiLevel ComboBox Field 
Multi Select ComboBox Field 
ListBox Field 
Multi Select ListBox Field 
HTML Editor Field  
FileUpload Field 
CheckBoxList Field 
RadioButtonList Field 
Validation - 9 
Required Fields 
Type Validation 
ReqEx & Custom Validation 
Validation Summary 
Validator Callout 
Validate Super Form inside Grid New 
Validate Custom DropDownListField New 
Validate using CompareValidator New 
Validate Linked Fields New 
Masks / Filters - 2 
Edit Masks 
Filters 
Linked Fields / Buttons - 4 
Enable / Disable Command Buttons 
Enable / Disable Linked Fields 
Show / Hide Linked Fields 
Conditional Linked Fields 
Client Side API - 1 
External Buttons New 
Server Side API - 1 
Focus New 
Localization - 1 
Localize Date Fields New 
Integration - 2 
Row Edit Template for Grid New 
Grid Editor inside Window New 
Knowledge Base - 1 
Knowledge Base 
Documentation - 6 
Server-Side 
ClientSideEvents 
Direction 
FieldSet 
FieldSetRow 
SuperForm 
ChangeLog