Setting SelectedIndexChanged event server side

8 posts, 0 answers
  1. Philip Senechal
    Philip Senechal avatar
    152 posts
    Member since:
    Apr 2008

    Posted 08 Apr 2011 Link to this post

    I have a combobox in a grid popup edit form that I'm creating programatically and I'm trying to set the SelectedIndexChanged event, but I can't seem to get it to fire.

    there are some data points that get read in to determine whether or not to set the SelectedIndexChanged event, but here is the code
    if (optionType == "ComboBox")
    {
        RadComboBox combo = new RadComboBox();
        combo.ID = "dd_" + option.ToString();
        combo.Font.Size = 8;
     
        if (optionName == "Report Date")
        {
            combo.AutoPostBack = true;
            combo.SelectedIndexChanged += new RadComboBoxSelectedIndexChangedEventHandler(dd_RptDate_SelectedIndexChanged);
        }
     
        foreach (var optionValue in q_optionValues)
        {
            combo.Items.Add(new RadComboBoxItem(optionValue.tReportOptionValue.OptNm, optionValue.tReportOptionValue.OptVal));
     
            // if option is Report Date, determine additional controls depending on dropdown value
            if (optionName == "Report Date")
            {
                //if optionvalue is specific date, set the datepickers bool to true
                if (optionValue.tReportOptionValue.OptNm == "Specific Date")
                {
                    datepickers = true;
                }
                //if optionvalue is specific months, set the monthpickers bool to true
                if (optionValue.tReportOptionValue.OptNm == "Specific Months")
                {
                    //datepickers = true;
                }
            }
        }
     
        panelContent.Controls.Add(combo);
    }

    I know I'm getting to the point where it should assign the SelectedIndexChanged event because the AutoPostBack attribute right above it is working (I can comment out that line and the combobox doesn't postback).

    Here is the associated event code
    protected void dd_RptDate_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        string url = "/";
        Response.Redirect(url);
     
        RadComboBox combo = (RadComboBox)sender;
     
        GridEditFormInsertItem editFormItem = (GridEditFormInsertItem)combo.NamingContainer;
        BuildOptions(editFormItem);
    }

    I put in the Response.Redirect just to see if the event was firing and it's not.

    Am I not going about this correct way? I need to be able to fire off this event so the BuildOptions event gets run when the postback occurs.

    Thanks
  2. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 13 Apr 2011 Link to this post

    Hi Philip,

    Could you please put a breakpoint into the SelectedIndexChanged event and debug the application?

    Greetings,
    Helen
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. Philip Senechal
    Philip Senechal avatar
    152 posts
    Member since:
    Apr 2008

    Posted 14 Apr 2011 Link to this post

    I wish I could, but this application will not work in debug mode because of the way it's being designed. I'm running Visual Studio on the development server because the login for that server has access rights to modify an enterprise level database. However, the user that the server runs under creates critical errors with authentication when I try to run the site locally in the Visual Studio environment.

    I would probably have to spend a couple of days coding around this just to get it to run locally where Visual Studio is installed and even then I don't know if I could get to the part of the application where the problem is occurring because there's another level of authentication based on Active Directory.

    I will try to pull this code out and set up a separate application without any of the authentication pieces. Might take me a day or so to get to that though. Would it be better if I opened up an official support ticket for this? We are both RadControls and Sitefinity customers. Thanks.
  4. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 15 Apr 2011 Link to this post

    Hello Philip,

    Yes, it would be better to open a support ticket and attach your code.

    In the meantime could you try to test the SelectedIndexChanged event by simply updating a label instead of calling the "Response.Redirect(url);"?

    Greetings,
    Helen
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  5. Philip Senechal
    Philip Senechal avatar
    152 posts
    Member since:
    Apr 2008

    Posted 15 Apr 2011 Link to this post

    I just attempted what you suggested and it worked. I added a Label to the grid's popup edit form with empty text. Inside my SelectedIndexChanged event, I located the control and updated the text to "FOUND IT". Upon changing the ComboBox that fires this event, the label updated to "FOUND IT".

    As expected, when I did this, the ComboBox that was created had additional blank items in the dropdown.
  6. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 15 Apr 2011 Link to this post

    Hello Philip,

    Do you use RadAjaxManager? If so, please try to call RadAjaxManager.Redirect instead of Response.Redirect.

    Regards,
    Helen
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  7. Philip Senechal
    Philip Senechal avatar
    152 posts
    Member since:
    Apr 2008

    Posted 15 Apr 2011 Link to this post

    I do use RadAjaxManager...the Response.Redirect was just a test to see if I was actually hitting the SelectedIndexChanged event, similar to you having me update a label. I just wanted to make sure the event is firing, which we've proved it is.

    The normal code execution won't have any type of redirect in it. All of my other redirects use RadAjaxManager.Redirect though.
  8. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 18 Apr 2011 Link to this post

    Hi Philip,

    If I understand you correctly the SelectedIndexChanged event fires as expected. Are there any outstanding issues?

    Regards,
    Helen
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top