dropdownlist触发事件的用法。。。
时间:2026-04-19 18:54:00
浏览:818次

后置代码:/// /// 绑定数据/// public void Data_Bind() { int Id= Convert.ToInt32(DropDownList1.SelectedValue); this.GridView1.DataSource = GetData_GridView(Id); //指定要根据DropDownList1中的ID获取数据源 this.GridView1.DataBind(); }/// /// 加载事件/// /// /// protected void Page_Load(object sender, EventArgs e){ if (!IsPostBack) { this.DropDownList1.DataSource = GetData_DropDownList1(); //DropDownList1中所需要绑定的数据 this.DropDownList1.DataTextField = "要显示的字段"; this.DropDownList1.DataValueField = "Id"; this.DropDownList1.DataBind(); Data_Bind(); }}/// /// 根据DropDownList当前选中的值查询/// /// /// protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e){ Data_Bind();}前台:这里自己设置吧