开发者

Drop Down List Event failed to execute

开发者 https://www.devze.com 2023-04-06 19:37 出处:网络
In my drop-down list, the SelectedIndexChanged event is not firing. I set AutoPostBack=\"True\" but it\'s still not firing. Setting EnableViewState to True or False makes no difference either.

In my drop-down list, the SelectedIndexChanged event is not firing. I set AutoPostBack="True" but it's still not firing. Setting EnableViewState to True or False makes no difference either.

Here's my code:

<asp:DropDownList ID="ddlSheerName" runat="server" Width="250" AutoPostBack="True"
 OnSelectedIndexChanged="ddlSheerName_SelectedIndexChanged"></asp:DropDownList>

protected void Page_Load(object sender, EventArgs e)
{
    loggedInUserId = Convert.ToString(Session["LoggedInUserId"]);
    if (loggedInUserId == "")
    {
        Response.Redirect("Login.aspx");
    }
    if (Page.IsPostBack == false)
    {
        BindCompanyDropDown();

    }
}

protected void ddlSheerName_SelectedIndexChanged(object sender, EventArgs e)
{
    Bindcolumnname();
}

public void BindCompanyDropDown()
{
    try
    {
        objData = new DBFile();
        DataSet dsCompanies = objData.GetCompaniesList(loggedInUserId);
        if (dsCompanies != null)
        {
            if (dsCompanies.Tables[0].Rows.Count > 0)
            {
                ddlselectcompany.DataSource = dsCompanies;
                ddlselectcompany.DataTextField = "CompanyName";
                ddlselectcompany.DataValueField = "CompanyID";
                ddlsele开发者_如何学编程ctcompany.DataBind();
            }
        }
    }
    catch (Exception ex)
    {
        lblMsg.Text = ex.Message;
    }
}


Viewstate must be enabled for this particular code to work and Javascript must be enabled for AutoPostBack to function.


The dropdown itself doesn't cause the event to fire.

You must actually change the selected item for the event to fire.


Is your event registred in the designer?
Select the dropdown and check the events assigned to it.

0

精彩评论

暂无评论...
验证码 换一张
取 消