Skip Navigation

  1. Tour
  2. Products & Pricing
    1. QuantumCMS Enterprise
    2. QuantumCMS Hosted
    3. QuantumCMS Lite
    4. Industry Solutions
      1. Legal / Law Firms
  3. Services
    1. Web Design
    2. SEO & Analytics
    3. Technical Support
  4. Examples
    1. Legal
    2. Healthcare
    3. Not-for-profit
    4. Industrial
    5. Other Industries
  5. Support
    1. Contact Us
    2. Community
    3. Frequently Asked Questions
    4. Tutorials
      1. Customizing the Dashboard
      2. Using the Navigation Tree
      3. Page Details
      4. Content Editor Guide
      5. Tips on Creating Effective Content
      6. Adding a Document Page
      7. 12 more items...
    5. Training Sessions
    6. Upgrades
      1. Obtaining Upgrades
      2. Installing Upgrades
  6. News
    1. Press
      1. Archive
    2. Company Announcements
      1. Growth Continues For Local High-Tech Sector Company
      2. Algonquin to be Official QR Code Sponsor of 2012 LMA Annual Conference
      3. Algonquin to Sponsor LMA Virginias 2011 Continuing Marketing Education Conference
      4. Algonquin Studios Announces Opening of New York City Office
      5. Algonquin Studios Announces Sponsorship of the New York State Academy of Trial Lawyers
      6. Tom Garigen Joins Algonquin Studios as Sales Consultant
    3. Clients
      1. Case Studies
      2. Testimonials
  7. Request Information

AS Web Forms : Design Patterns : Limit a dropdown on the Web Forms based on a value in another dropdown.

Limit a dropdown on the Web Forms based on a value in another dropdown.

Sometimes, you may have a set of drop downs on a single AS Web Form that rely on one another. For an example, consider State and County.

The following pattern may be used on the page hosting the ASWebForms ASDataEditor control:

In your code behind, add an object to server as a reference to your data editor:

Protected WithEvents ctlASDataEditor As ASWebForms.AlgonquinStudios.Controls.ASDataEditor

Then, set a reference to this in the Page_Load event:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ctlASDataEditor = Me.FindControl("ctlASDataEditor")
End Sub

Finally, add code to the ctlASDataEditor_PreRender event which will perform the appropriate look-up changes and reset the drop down:

Private Sub ctlASDataEditor_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles ctlASDataEditor.PreRender
Dim cboState As System.Web.UI.HtmlControls.HtmlSelect
Dim htParameters As Hashtable
Dim intStateIdent As Int32
Dim dsResults As System.Data.DataSet
Dim dv As System.Data.DataView
Dim intCountyIdent As Int32
cboState = Helper.GetControl(ctlASDataEditor, "StateIdent")
cboState.Attributes.Add("onchange", "forms[0].submit();")
intStateIdent = CType(Helper.GetControl(ctlASDataEditor.pnlDataControls, ("State")), System.Web.UI.HtmlControls.HtmlSelect).Value
intCountyIdent = CType(Helper.GetControl(ctlASDataEditor.pnlDataControls, ("CountyIdent")), System.Web.UI.HtmlControls.HtmlSelect).Value
With CType(Helper.GetControl(ctlASDataEditor.pnlDataControls, ("CountyIdent")), System.Web.UI.HtmlControls.HtmlSelect)
htParameters = New Hashtable
htParameters.Add("@intStateIdent", intStateIdent)
If Me.Helper.CallStoredProcedure("uspGetActiveCountyByStateIdent", htParameters, 0, 0, dsResults, dsMessage) Then
.DataSource = dsResults.Tables(0).DefaultView
End If
.DataBind()
.Items.FindByValue(intCountyIdent.ToString).Selected = True
End With
End Sub