1、ASPxListBox 数据绑定 Item 添加 删除
DevExpress 官方帮助:
The ASPxListBox control allows you to modify the ASPxListEdit.Items collection on callbacks only (e.g. add and remove items, populate the controls with new data from a data source, etc.).
It is not possible, for example, to modify a column collection, change items selection, or change SelectionMode on callbacks. To perform these actions on the client side, you can wrap the control with theASPxCallbackPanel control and process a required scenario on a callback to the panel.
添加删除Item只能在callback事件中处理,客户端调用语句:
<dx:ASPxButton ID="btnDeleteUpload" runat="server" Text="删除已有" AutoPostBack="false"
Style="margin: 16px auto;">
<ClientSideEvents Click="function(s, e) { listAttachment.PerformCallback(listAttachment.GetSelectedIndex());}" />
</dx:ASPxButton>
PerformCallback的参数可以传递要删除的ItemIndex。
服务器端:protected void listAttachment_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e) 中处理数据绑定或者删除Item ,利用e.Parameter的值来判断。