4月 01, 2010

gridview的連動式下拉選單


protected void ddlDepNum_1Level_DataBound(object sender, EventArgs e)

    {


        DropDownList ddl_tmp_dep = ((DropDownList)sender); //上層 部門資料


        DropDownList ddl_tmp_emp = ((DropDownList)sender).NamingContainer.FindControl("ddl_emp") as DropDownList; //下層 部門員工資料


        SqlDataSource SqlDataSource_emp = ((DropDownList)sender).NamingContainer.FindControl("sdsEmpNum") as SqlDataSource; //下層的datasource


        SqlDataSource_emp.SelectParameters["Dept"].DefaultValue = ddl_tmp_dep.SelectedValue; //上層的部門代碼參數


        ddl_tmp_emp.DataBind();


    }


 


 


ddlDepNum_1Level_SelectedIndexChanged() 事件也一併使用

沒有留言: