Solved

Cascading DDL, Inside DetailsView, using MS Access and VB.NET/ASP.NET new records

Posted on 2010-11-11
3
426 Views
Last Modified: 2012-05-10
Very specific question - please read.

I have a DetailsView Control on my ASP.NET Page (VB NOT C#)
On my Form I have 2 drop down lists. DDL1 and DDL2 that come from 2 lookup tables that are not part of the main table. DDL2 cascades from DDL1. The Main table has 2 fields, DDL_fk1 and DDL_fk2 that take integer values from the DDLs on the form.
Using MSAccess for backend.

I have functioning cascading code and am able to load the values in the 2 DDLs just fine.

My problem is that if the record does not currently have values in the underlying fields, it throws an error. In other words, if there has NOT been a selection made for either DDL, they should load with DDL1 stating "Please Make a Selection" and DDL2 being disabled.

Instead, I get an error.

Please provide WORKING syntax and code examples.
0
Comment
Question by:DLockwood
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 34113691
How about this in the sample:

Protected Sub ddlPlacementTypes_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim ddlPlacementTypes As DropDownList = DirectCast(sender, DropDownList)
        If String.IsNullOrEmpty(ddlPlacementTypes.SelectedValue) Then
            Typeid = -1
        Else
            Typeid = ddlPlacementTypes.SelectedValue
        End If
        PlacementSubType_DS.SelectParameters(0).DefaultValue = Typeid
    End Sub

Note: There will appear a  link "ask a related question" in the Post Comment section for a closed question. Since this question is kind of related to previous question you can use that feature. This helps other experts to better understand your question and build upon the previous one.
0
 

Author Comment

by:DLockwood
ID: 34113788
I didn't know about the "ask a related question" link. Thanks.

Well, I am sure you never thought I would say it, but the page is completely functional and doing everything that it is supposed to do.

I have 9 other pages for different programs (other than crisiscare) that all use the same PlacementType and PlacementSubType cascading DDLS. So, now all I have to do is copy the functionality into all of the pages and test. Tedious but easy.

THANK YOU again for all of your help. I could not have done it without you!
0
 

Author Closing Comment

by:DLockwood
ID: 34113793
Awesome!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question