/// <summary> /// 绑定代表下拉选项 /// </summary> public void BindOwnerDataII(string unitId, string bindid) { BaseCore obj = new BaseCore(); DataTable dt = obj.GetOwnerByBusiness(unitId); this.ddlOwner.DataSource = dt; this.ddlOwner.DataTextField = "fullname"; this.ddlOwner.DataValueField = "systemuserid"; this.ddlOwner.DataBind(); this.ddlOwner.SelectedValue = bindid; //这个放在前面,好像没有问题, this.ddlOwner.Items.Insert(0, new ListItem("全部", "00000000-0000-0000-0000-000000000000")); this.ddlOwner.SelectedValue = bindid; //这个放在后面,就有问题了. }
放在后面的话,在第一次加载的时候是有问题的,也就是说 this.ddlOwner.SelectedValue 这段代码取的值为空值,但是如果放在前面就没有问题了.
时间: 2024-10-07 09:46:15