Last post Jan 21, 2009 10:16 PM by Nai-Dong Jin - MSFT
Jan 19, 2009 06:14 AM|saurin143|LINK
i have a xml file like
<?xml version="1.0" encoding="UTF-8"?>
<country value="5" name="UK" >
<state value="12" name="Bedforshire">
<city name="Ampthill" value="6438"></city>
<state value="13" name="Berkshire">
<city name="Aldermaston" value="3916"></city>
<state value="16" name="Buckinghamshire">
<city name="Amersham" value="3736"></city>
<state value="18" name="Cambridgeshire">
<city name="Abington" value="3896"></city>
now when i select country in dropdownlist then
it display its related state in from above xml file to dropdownlist of state
and when i select state then its display its related city in dropdownlist of city.
how to make such a CUSTOM CONTROL in asp.net my backend language is vb.
Jan 21, 2009 10:16 PM|Nai-Dong Jin - MSFT|LINK
From your description, you want to create a custom server control which involves a related dropdownlist, right?
You mentioned that the datasource is an XML file, so I suggest that you need to parse the XML document to an DataTable first, generally we can use ReadXML method of a DataSet object. For more information on this step, see:
After you get the DataTable, you can use rowFilter to seek for the children value based on the selected value from the parent dropdownlist control. And bind the value you found from the datatable to the child dropdownlist.
And then, create a DataboundCompositeControl, expose some events (e.g SelectedChanged) and some properties (e.g DataSource of DropDownList). When the selected value changes from dropdownlist, yo may filter the dataset in SelecteChanged event, and add the
filtered datatable to Child DropDownList's DataSource property of your custom server control.
For more information on creating databound composite control, see: