lookupedit控件中用EditValueChanged事件完成省市联动,为什么选择几次省就会出现几次市?(多次选择市之后区也是这个问题),怎么解决?
private void sheng_EditValueChanged(object sender, EventArgs e)
{
DataTable shiTb = SqlHelper.Query(" select org_id,gw_organization.`name` as org_name FROM gw_organization where length(org_id)=4 and org_id like '" + sheng.EditValue + "%' ", 0);
if (shiTb != null)
{
this.shi.Properties.ValueMember = "org_id";
this.shi.Properties.DisplayMember = "org_name";
this.shi.Properties.DataSource = shiTb;
this.shi.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
this.shi.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo(this.shi.Properties.DisplayMember));
if (!string.IsNullOrEmpty(_addr.City))
{
var InitValue = from r in shiTb.AsEnumerable()
where r.Field<string>("org_name") == _addr.City
let objectArray = new object[]
{
r.Field<string>("org_id")
}
select objectArray;
shi.EditValue = InitValue.ToList()[0][0];
}
}
}
private void shi_EditValueChanged(object sender, EventArgs e)
{
DataTable quTb = SqlHelper.Query(" select org_id,gw_organization.`name` as org_name FROM gw_organization where length(org_id)=6 and org_id like '" + shi.EditValue + "%' ", 0);
if (quTb != null)
{
this.qu.Properties.ValueMember = "org_id";
this.qu.Properties.DisplayMember = "org_name";
this.qu.Properties.DataSource = quTb;
this.qu.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
this.qu.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo(this.qu.Properties.DisplayMember));
if (!string.IsNullOrEmpty(_addr.District))
{
var InitValue = from r in quTb.AsEnumerable()
where r.Field<string>("org_name") == _addr.District
let objectArray = new object[]
{
r.Field<string>("org_id")
}
select objectArray;
qu.EditValue = InitValue.ToList()[0][0];
}
}
}