Need help with CascadingDropDown

Last post 08-20-2008 4:51 AM by shy_sandeep. 5 replies.

Sort Posts:

  • Need help with CascadingDropDown

    08-13-2008, 3:30 AM
    • Member
      point Member
    • shy_sandeep
    • Member since 05-29-2007, 12:45 AM
    • Posts 5

    Hi,

    I've have seen how CascadingDropDown control works. However in my case what i need is..   4 DropDownLists (combo boxes), each gets populated from db at page load. Now if value of any DropDownListBox gets changed; i want all other 3 DropDownListBoxes to again load data based on different criteria.

    Can i get AJAX CascadingDropDown to work in this senario?

    Any sample code/ links would be helpful.

    Thanks,

    Sandeep.

    Filed under:
  • Re: Need help with CascadingDropDown

    08-15-2008, 4:37 AM
    Answer

    Hi,

    CascadingDropDown is based on the Child-Parent structure. But what you want is based on a parallel structure. Implementing parallel stucture by using CascadingDropDown will modify the whole architecture of it. It's not recommendable.

    My suggestion is using UpdatePanel and DropDownList to implement this functionality without refreshing.

     

        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"   AppendDataBoundItems="true"
                    onselectedindexchanged="DropDownListUpdate">
                <asp:ListItem Selected="True" Value="-1" >Please Select</asp:ListItem>
                </asp:DropDownList>
                <br />
                <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True"  AppendDataBoundItems="true"
                    onselectedindexchanged="DropDownListUpdate">
                <asp:ListItem Selected="True" Value="-1">Please Select</asp:ListItem>
                </asp:DropDownList>
                <br />
                <asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True"  AppendDataBoundItems="true"
                    onselectedindexchanged="DropDownListUpdate">
                <asp:ListItem Selected="True" Value="-1">Please Select</asp:ListItem>
                </asp:DropDownList>
                <br />
                <asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True"  AppendDataBoundItems="true"
                    onselectedindexchanged="DropDownListUpdate">
                <asp:ListItem Selected="True" Value="-1">Please Select</asp:ListItem>
                </asp:DropDownList> 
            
            </ContentTemplate>
        </asp:UpdatePanel>
    
        <br />
      
     
        protected void DropDownListUpdate(object sender, EventArgs e)
        {
            if(((DropDownList)sender).SelectedValue!="-1")
                BindUpdate((DropDownList)sender);
            
        }
    
        protected void BindUpdate(DropDownList ddl)
        {
            //"ddl" is the active DropDownList you click. Please update other three DropDownlist Controls according to the Selected DropDownList ID and Value.
    
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "script", "alert('updated');", true);
        }
     

    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Need help with CascadingDropDown

    08-20-2008, 3:55 AM
    • Member
      point Member
    • shy_sandeep
    • Member since 05-29-2007, 12:45 AM
    • Posts 5

    Thanks Vince,

    This solution works, however i'm having some problem with this. After implementing this, when i click the 1st drop down it says updated. But next time when i click other item of same dropdown, it gives following error.

    Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originates from the server control that originally rendered them. If the data is valid and expected, use the ClientScripManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

     

  • Re: Need help with CascadingDropDown

    08-20-2008, 4:03 AM
    • Member
      point Member
    • shy_sandeep
    • Member since 05-29-2007, 12:45 AM
    • Posts 5

    hey,

    for now i've used...

    <system.web>

    <pages enableEventValidation="false">

    not sure if its the correct solution.

  • Re: Need help with CascadingDropDown

    08-20-2008, 4:45 AM

    Hi,

    Yes, that's it. It will not validate the post value. But I suggest you set it at the page rather than at web.config.

    For example:

    <%@ Page Language="C#" AutoEventWireup="true"

    EnableEventValidation="false"

     CodeFile="Default.aspx.cs" Inherits="_Default" %>

     


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Need help with CascadingDropDown

    08-20-2008, 4:51 AM
    • Member
      point Member
    • shy_sandeep
    • Member since 05-29-2007, 12:45 AM
    • Posts 5

    Works great.

    Thanks a lot..

Page 1 of 1 (6 items)