1

//我的问题是,当我异步触发 ddlmodalitylist 的 SelectedIndexChanged 事件(ajax 调用)时,不会触发 javascript 加载事件。这就是你必须从服务器端触发 onload 事件。

window.onload = body_Onload;

     function body_Onload() {
        //javascript code
       }

    protected void ddlModalityList_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddlStudy.Items.Clear();
            ListItem selectedPair = ddlModalityList.SelectedItem;
            string str= selectedPair.Value;

           int ID= Convert.ToInt32(str);

           if (ID == -1)
           {
              // ddlStudy.Items.Clear();
               return;
           }



            DataTable dataTableStudy = null;
            dataTableStudy = objSqlDbComm.ExecuteDatasetQuery(strSQL).Tables[0];

            var dictioneryStudy = new Dictionary<int, string>();
            foreach (DataRow dr in dataTableStudy.Rows)
            {          

                dictioneryStudy.Add(Convert.ToInt32(dr["Study_ID"]), dr["Study_Desc"].ToString());
            }

            ddlStudy.DataTextField = "Value";
            ddlStudy.DataValueField = "Key";
            ddlStudy.DataSource = dictioneryStudy;
            ddlStudy.DataBind();
            ddlStudy.Items.Insert(0, new ListItem("[Select]", "-1"));
            ddlStudy.Items[0].Selected = true;

        }
4

1 回答 1

0
Sys.Application.add_init(your_bodyload_function);
于 2012-05-24T06:19:45.437 回答