Note the following when using cascadingdropdownlist:
(1) You can only use this control through web service.
(2) The created web service is as follows: [System. Web. Script. Services. scriptservice]
[WebService (namespace = " Http://tempuri.org/ " )]
[Webservicebinding (conformsto = Wsiprofiles. basicprofile1_1)]
Public Class Basictypes: system. Web. Services. WebService
{
PublicBasictypes ()
{
// Uncomment the following line if using designed components
// Initializecomponent ();
}
[Webmethod]
Public Ajaxcontroltoolkit. cascadingdropdownnamevalue []Getdropdowncontents( String Knowncategoryvalues, String Category)
{
Datatable dt = Getdatatable ( " Select * From basictype " );
List < Ajaxcontroltoolkit. cascadingdropdownnamevalue > Values = New List < Ajaxcontroltoolkit. cascadingdropdownnamevalue > ();
Foreach (Datarow Dr In DT. Rows)
{
Values. Add ( New Ajaxcontroltoolkit. cascadingdropdownnamevalue (Dr [ " Type " ]. Tostring (), Dr [ " ID " ]. Tostring ()));
}
Return Values. toarray ();
}
}
Note red Code .
In the PAGE method of cascadingdropdownlist, that is, in the background code of the page using this control, the name of the (3) webmethod called in Web service must be the same as the webmethod set in the control. As shown in bold and purple: < Ajaxtoolkit: cascadingdropdown ID = "Ccddatatypeparents" Runat = "Server" Enabled = "True"
Servicemethod ="Getdropdownparents" Parentcontrolid = ""
Usecontextkey = "True" Servicepath = "Basictypes. asmx"
Targetcontrolid = "Ddldatatypeparents"
Category = "Datatypeparentsid" Prompttext = "Select parent type"
Loadingtext = "Loading parent type" Selectedvalue = "" >
</ Ajaxtoolkit: cascadingdropdown >
(4) use pagemethod as follows: [Webmethod]
[System. Web. Script. Services. scriptmethod]
Public Static Ajaxcontroltoolkit. cascadingdropdownnamevalue [] getdropdownparents ( String Knowncategoryvalues, String Category)
{
Return New Basictypes (). getdropdownparents (knowncategoryvalues, category );
}
Be sure to add the purple code section. The system will generate the purple part by itself, but it is different, so you just need to replace the automatically generated part of the system (I have not tried to replace it, but it can work now ).
When Error 500 occurs, check the precautions mentioned above.