昨天在实现一个"仓库"和"库位"下拉框联动时,使用ASPxComboBox的OnSelectedIndexChanged始终没有效果,今天查询了下ASPxComboBox的使用方法才发现使用的方法错误了。在这记录下,也感谢博主分享ASPxComboBox使用方法
前端:
<dxe:ASPxComboBox ID="cbxWH" ClientInstanceName="cbxWH" runat="server" Width="100px">
<ClientSideEvents SelectedIndexChanged="function(s, e) {cbxLocation.PerformCallback();}" />
</dxe:ASPxComboBox>
<dxe:ASPxComboBox ID="cbxLocation" oncallback="cbxLocation_Callback" ClientInstanceName="cbxLocation" runat="server" Width="100px">
</dxe:ASPxComboBox>
cs事件:
protected void cbxLocation_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
{
#region 库位
cbxLocation.DataSource = null;
cbxLocation.DataBind();
var whCd = cbxWH.Value != null ? cbxWH.Value.ToString() : "";
var where = string.Empty;
if (!string.IsNullOrEmpty(whCd))
where = " WH_CD = '" + whCd + "' ";
EditorBinder.BindMesLocationCD(cbxLocation, where, true);
#endregion
}
效果: