First Item in dropdownlist doesn't fire SelectedIndexChanged at all

后端 未结 7 2062
盖世英雄少女心
盖世英雄少女心 2021-02-20 12:24

I have following simple code:

<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"testForm.aspx.cs\" Inherits=\"Orbs.testForm\" %>

         


        
7条回答
  •  迷失自我
    2021-02-20 12:49

    Had the same issue - SelectedIndexChanged doesn't fire when selecting the first option, My not clean solution was (not sure that was so smart but it work for me),

    At the Page_Load I added the follow script:

    if (!IsPostBack)
            {
    
                //bind data first time
            }
            else
            {
                int ddlSortByValue = int.Parse(ddlSortBy.SelectedValue);
                if (ddlSortByValue == 0)
                {
                    ddlSortBy_SelectedIndexChanged(this, EventArgs.Empty);
                }
    
            }
    

    That way I force the SelectedIndexChanged event to fire up

提交回复
热议问题