Hi sunny74,
1. Let’s clarify the function of the CascadingDropDown. In the description of the CascadingDropDown, it is mentioned that: CascadingDropDown enables a common scenario in which the contents of one list depends on the selection of another list and does so without having to embed the entire data set in the page or transfer it to the client at all. All the logic about the contents of the set of DropDownList controls lives on the server in a web service.
This means the CascadingDropDown would help us build the DropDownList’s options based on the service method’s returned value in the web service instead of we build the options manually at the client side. That’s why the DropDownList is only a blank tag without any ListItem:
<asp:DropDownList ID="ddlColors" runat="server" Width="240px" />
<ajaxToolkit:CascadingDropDown ID="cddColors"
runat="server"
TargetControlID="ddlColors"
ParentControlID="ddlModels"
Category="Color"
PromptText="Choose a Color...."
LoadingText="Please wait ..."
ServicePath="CarsService.asmx"
ServiceMethod="GetColors">
Besides, all the events of calling web service and changing the child’s options are dynamically client event. We can not control these events from the code-behind but client side. So, in the Button server click event, we can not change the DropDownList’s SelectedItem’s text. To set the DropDownList’s selection to the initialize value, we can use this client method:
<asp:Button ID="btnReset" Text="Reset" runat="server" OnClientClick="resetClicked();return false;" />
<script type="text/javascript">
function resetClicked() {
var cdd = $find('the CascadingDropDown’s BehaviorID');
cdd.set_SelectedValue(cdd._promptText);
}
</script>
2. Most of the AjaxControlToolkit extenders only fire their events from the client side, but some extenders enable us to handle their server side events, such as TabContainer’s ActiveTabChanged (Event), Rating control’s AutoPostBack can be set as true, and so on.
3. To achieve your goal without the CascadingDropDown extenders, you can follow these steps:
.Build a new web site with your DropDownLists and DataBase.
.Set all the DropDownLists’ AutoPostBack property with true.
.In PageLoad function, bind the first DropDownList with the DataBase.
.In each DropDownList’s SelectedIndexChanged event, rebind the child DropDownList’s Data by the selection of their parent’s selection.
For example:
Protected Sub ddlModels_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlModels.SelectedIndexChanged
Dim carMakeAdapter As New dsCarsTableAdapters.CarsTableAdapter()
ddlMakes.Enabled = True
'Please modify the DataAdapter's method by yourself
ddlMakes.DataSource = carMakeAdapter.GetCarsByModel(ddlModels.SelectedItem.Text)
ddlMakes.DataValueField = "CarId"
ddlMakes.DataTextField = "CarName"
ddlMakes.DataBind()
End Sub
.At the client side, place all the controls into an UpdatePanel.
The difference between this method and using the CascadingDropDown is:
In this method, the UpdatePanel helps us change the classic server events of the DropDownLists to dynamic events.
The CascadingDropDown extender is an Ajax control, it would achieve the partial-refresh cascading function automatically.
Best regards,
Zhi-Qiang Ni