在模态弹出窗口中没有触发选定的索引更改事件?

时间:2012-10-13 21:19:13

标签: asp.net selectedindexchanged

我有以下代码应该以模态弹出方式运行:

#region events


protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        dt = DataObj.GetDataTable("GetScheduleNames");
        foreach (DataRow myrow in dt.Rows)
        {
            SchedNameLst.Add(Convert.ToString(myrow["ScheduleName"]));
        }
        SchedNameListDD.DataSource = SchedNameLst;
        SchedNameListDD.DataBind();

    }
}

 protected void SchedNameListDD_SelectedIndexChanged(object sender, EventArgs e)
{
    // should be in selected index fired event
    SchedName.Text = SchedNameListDD.SelectedItem.Text;
    string name = SchedNameListDD.SelectedItem.Text;
    dt = DataObj.GetDataTable("GetSchedDetails", name);

    foreach (DataRow myrow in dt.Rows)
    {
        StartTime.Text = myrow["StartTime"].ToString();
        EndTime.Text = myrow["EndTime"].ToString();
    }
    dt = DataObj.GetDataTable("GetSchedDetailsSat", name);
    foreach (DataRow myrow in dt.Rows)
    {
        SatSt.Text = myrow["StartTime"].ToString();
        SatEt.Text = myrow["EndTime"].ToString();
    }
 }


#endregion

当我在下拉列表中更改我的项目选择时,我的selectedIndexChanged事件不会被触发..是这样的吗?

2 个答案:

答案 0 :(得分:0)

  1. 确保您已在控件上启用了AutoPostBack,即AutoPostBack = "true"
  2. 通过在Page或UserControl指令中设置EnableViewState="true",确保启用了viewstate

答案 1 :(得分:0)

使用onchange =&#34; javascript:__ doPostBack(&#39; 下拉列表&#39; <#> Patameters &#39;)&# 34;