How to detect dropdownlist event in Datagrid Footer?

Last post 01-30-2007 10:12 AM by sg2000. 4 replies.

Sort Posts:

  • How to detect dropdownlist event in Datagrid Footer?

    01-29-2007, 1:26 PM
    • Loading...
    • sg2000
    • Joined on 05-04-2003, 11:34 AM
    • Posts 153

    Hi Everyone:

             I have 3 dropdownlist (ddl)  in my Datagrid Footer, one is ddlParent, the others are ddlChild and dd;GrandChild. All of these are populated with respective items from the database. I would like that whenever the user selects a value from ddlParent, the items in the ddlChild will automatically be updated so that it contains only the subset that is relevant to the selected item in ddlParent. Likewise, whenever the user selects a value from ddlChild, the items in the ddlGrandChild will automatically be updated.

            I would appreciate it very much if someone can tell me what event will be raised when any of the ddl's in the Footer has been selected, and how can I determine which of the ddl's was selected? I work with Framework 1.1.

           Thanks in advance.

           sg2000

     

     

     

    Filed under: , , ,
  • Re: How to detect dropdownlist event in Datagrid Footer?

    01-29-2007, 1:40 PM
    • Loading...
    • ecbruck
    • Joined on 12-30-2005, 2:39 PM
    • Des Moines, IA
    • Posts 7,995
    • Moderator
      TrustedFriends-MVPs
    You will want to set-up a handler for the DropDownList.SelectedIndexChanged event. Make sure to also set the DropDownList.AutoPostBack property to true.
    Thanks, Ed

    Microsoft MVP - ASP/ASP.NET

  • Re: How to detect dropdownlist event in Datagrid Footer?

    01-29-2007, 3:40 PM
    • Loading...
    • sg2000
    • Joined on 05-04-2003, 11:34 AM
    • Posts 153

    ecbruck:

    Thanks for the response. Yes, I have a handler for dor the DataGrid.SelectedIndexChanged event and set the ddl autopostback to true. (I cannot set the SelectedIndexChanged event for the ddl's in the footer). However, no event was fired when I select a value from any of the ddl's. Also, in the event I do get an event, how can I tell from which ddl it comes? Hope you can explain.

    Thanks again.

     sg2000

  • Re: How to detect dropdownlist event in Datagrid Footer?

    01-30-2007, 5:21 AM
    Answer

    Hi, sg2000:

    Make sure you do not bind your datagrid on each postback in Page_Load() event.

    protected void Page_Load()
    {
             if(!IsPostBack)
                //Bind your datagrid

    }

    Run the sql and make sure your DataValueField returns Unique values.

    Best Regards,
    __________________________________________________
    Sincerely,
    Rex Lin
    Microsoft Online Community Support

    If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
  • Re: How to detect dropdownlist event in Datagrid Footer?

    01-30-2007, 10:12 AM
    • Loading...
    • sg2000
    • Joined on 05-04-2003, 11:34 AM
    • Posts 153

    Hi Rex:

         Thank very much for the response.

        Yes, I did solve the problems I encountered with cascading dropdownlists (ddl) in datagrid footer. As suggested by you and poster ecbruck, there are 4 things that one should do:

         1. Make sure you use if (!Page.IsPostBack) in Page_Load method

         2. Make sure you set  AutoPostBack="True" for the ddl's

         3. Make sure you specify  a handler for the OnSelectedIndexChanged of the ddl

        and, last but not least,

         4. Make sure the handler for the OnSelectedIndexChanged of the ddl is declared as public (not private)

         Thanks again.

         sg2000 

     

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter