ASP.Net using VB.Net: Having issues with Ajax CascadingDropDownList (1 Viewer)

smichaels1234

Registered User.
Local time
Today, 17:14
Joined
May 12, 2008
Messages
64
Hi all,
I am hoping that someone might know the answer to this. I have built just a simple form in VS.Net 2005 using Ajax controls. I have a form that has 2 Drop Down Lists called ddlBusinessUnit and the other called ddlUnitNum. I dragged 2 CascadingDropDownLists to the Form as well. In each I set there parameters for Child and Parent Lists. ddlBusinessUnit is the Parent and ddlUnitNum is the Child. I also created a webservice and this is where all of my code behind is going. The problem that I am having is that I am creating 2 different Functions which are here:

<WebMethod()> _
Public Function GetBusinessUnit(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
Dim values As New List(Of CascadingDropDownNameValue)
Dim conn As New SqlConnection(WebConfigurationManager.ConnectionStrings("PS_PRODConnectionString").ConnectionString)
Dim comm As New SqlCommand("SELECT DISTINCT NBMCU, NBUNIT FROM PRODDTA.F1521", conn)
Dim reader As SqlDataReader
reader = comm.ExecuteReader
While reader.Read
values.Add(
New CascadingDropDownNameValue(reader("NBMCU").ToString(), reader("NBUNIT").ToString()))
End While
Return values.ToArray
End Function
<WebMethod()> _
Public Function GetUnitNum(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
If Not (kv.ContainsKey("NBMCU")) Then
Return Nothing
End If
Dim values As New List(Of CascadingDropDownNameValue)
Dim conn As New SqlConnection(WebConfigurationManager.ConnectionStrings("PS_PRODConnectionString").ConnectionString)
Dim comm As New SqlCommand("dbo.SP_PRODDTA_F1521_UnitNum", conn)
comm.CommandType = Data.CommandType.StoredProcedure
Dim ad As New SqlDataAdapter(comm)
Dim ds As New DataSet
ad.Fill(ds)
For Each row As DataRow In ds.Tables(0).Rows
values.Add(
New CascadingDropDownNameValue(row("NBUNIT").ToString(), row("NBMCU").ToString()))
Next
Return values.ToArray
End Function

And the problem that I am having is here:

values.Add(New CascadingDropDownNameValue(reader("NBMCU").ToString(), reader("NBUNIT").ToString()))

Because I want to only have 1 "NBMCU" Field in this expression like so:

values.Add(New CascadingDropDownNameValue(reader("NBMCU").ToString()))

So my question is what can I do to specify only 1 field and no other fields.
 

dan-cat

Registered User.
Local time
Today, 22:14
Joined
Jun 2, 2002
Messages
3,433
I haven't worked with this object before and couldn't find any documentation for it.

However if the constructor of the CascadingDropDownNameValue object demands 2 variables then it looks like that's what you're going to have to supply.

More evidence that 2 variables are required is the use of a dictionary object within the function CascadingDropDown.ParseKnownCategoryValuesString(k nownCategoryValues). Dictionaries require a name,value pair, so I'm assuming each CascadingDropDownNameValue require a name,value pair for this to work off.

This is all guess work really. As I said, never worked with this object before.
 

Users who are viewing this thread

Top Bottom