Hi all,
in one of my pages, i have two dropdowns: one for listing countries and the second for listing the states/provinces of the country selected in the first one dropdown.
When i was using the AJAX Release candidate version, I used the cascadingdropdown without problem. But when i installed the v1.0, the cascadingdropdown stop updating the second dropdown, as used to. Is there someone who can tell me what i am doing wrong?
 Part of my code in the aspx file:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:UpdatePanel id="UpdatePanel1" runat="server" UpdateMode="Conditional" RenderMode="Inline">
    <ContentTemplate>
    <TABLE style="WIDTH: 100%; TEXT-ALIGN: left">
    <TBODY> <TR>
                        <TD style="WIDTH: 328px; TEXT-ALIGN: left">
                       <asp:DropDownList id="CountryDropDownList" tabIndex=12 runat="server" Width="204px" AutoPostBack="True" DataTextField="Name" DataValueField="Id"></asp:DropDownList>
                        </TD>
                        <TD style="WIDTH: 328px; HEIGHT: 24px; TEXT-ALIGN: left">
                        <asp:DropDownList id="ProvinceDropDownList" tabIndex=12 runat="server" Width="204px" DataTextField="Name" DataValueField="Id"></asp:DropDownList>
                        </TD>
     </TBODY>
     </TABLE>
<cc1:CascadingDropDown id="CascadingDropDown1" runat="server" TargetControlID="CountryDropDownList" Category="Country" ServicePath="CustomerSignUp.aspx" ServiceMethod="GetAllCountries" PromptText="<%$ Resources:Messages, SelectCountry %>" LoadingText="<%$ Resources:Messages, Loading %>"></cc1:CascadingDropDown>
<cc1:CascadingDropDown id="CascadingDropDown2" runat="server" TargetControlID="ProvinceDropDownList" Category="Province" ServicePath="CustomerSignUp.aspx" ServiceMethod="GetCountryProvinces" PromptText="<%$ Resources:Messages, SelectProvince %>" LoadingText="<%$ Resources:Messages, Loading %>" ParentControlID="CountryDropDownList"></cc1:CascadingDropDown>  
</ContentTemplate>
</asp:UpdatePanel>  
</asp:Content>
Methods in the aspx.cs file:
[WebMethod]   
    public static CascadingDropDownNameValue[] GetAllCountries(string knownCategoryValues, string category)
    {
        List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
        ICollection<Country> countries = KinocastFacade.Instance.GetAllCountries();
        foreach (Country country in countries)
        {
            values.Add(new CascadingDropDownNameValue(
            Resources.Messages.ResourceManager.GetString(country.Name), country.Id.ToString()));
        }
return values.ToArray();
    }
[WebMethod]   
    public static CascadingDropDownNameValue[] GetCountryProvinces(string knownCategoryValues, string category)
    {       
        StringDictionary kv = CascadingDropDown.ParseKnownCategoryValuesString(
          knownCategoryValues);
        int countryId;
        /*Verifica se a chave country está no StringDictionary e se é possivel
         *fazer o parse do seu valor para inteiro. Se possivel coloca o valor
         *em countryId*/
        if (!kv.ContainsKey("Country") ||
            !Int32.TryParse(kv["Country"], out countryId))
        {
            return null;
        }
        List<CascadingDropDownNameValue> values = new List<CascadingDropDownNameValue>();
        ICollection<Province> provinces = KinocastFacade.Instance.GetCountryProvinces(countryId);       
        foreach (Province province in provinces)
        {
            values.Add(new CascadingDropDownNameValue(
            Resources.Messages.ResourceManager.GetString(province.Name), province.Id.ToString()));
        }
       
        return values.ToArray();
    } 
Thanks a lot for any help,
Rodrigo
Anyway,
I've just resolved my problem re-creating the project, including all my files and modules again. And at the end, i include the AjaxControlToolkit.dll (version 1.0.10301.0) and the cascadingdropdown problem disapeared.
Maybe, it had happened because the VS saves some olds DLLs in a limbo place :p ...... I dont know...
Cheers.
 
 
No comments:
Post a Comment