[英]AspxCheckbox List Selected Items are not deleted based on the selecteditems in Asp.net C#
I want to remove single or grouped selected items from the AspxCheckbox list control(devexpress control) by button click. 我想通过单击按钮从AspxCheckbox列表控件(devexpress控件)中删除单个或分组的选定项目。 I am using the following code.
我正在使用以下代码。 It deleted the first single selected item fine.
它删除了第一个选定的罚款项目。 When I select 5 items(index 5, 6, 7,8) among 10. it starts to delete from 5th position to top positioned items(index 5, 4, 3) which are not selected.
当我在10个中选择5个项(索引5、6、7、8)时,它开始从第5位删除到未选中的最上面的项(索引5、4、3)。 Please help me fix this.
请帮我解决这个问题。
protected void cbpNDTStaffs_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e)
{
if (e.Parameter == "RemoveNDTStaff")
{
string Message = string.Empty;
int i;
for (i = 0; i <= ChklstNDTStaffs.SelectedItems.Count - 1; i++)
{
string EmpIDAndName = string.Empty;
string EID = "";
if (ChklstNDTStaffs.SelectedItems[i].Selected)
{
EmpIDAndName = Convert.ToString(ChklstNDTStaffs.SelectedItems[i].Text);
EID = Convert.ToString(ChklstNDTStaffs.SelectedItems[i].Value);
Int64 ReturnValue = DataAccess.NDTDataAccess.UpdateNDTStaffs(EID, CurrentlyLoggedUserName);
if (ReturnValue > 0)
{
Message = "Selected NDT Staff(s) Removed Successfully.";
}
}
}
if (Message.Length > 0)
{
ChklstNDTStaffs.DataBind();
cbpNDTStaffs.JSProperties["cpIsUpdated"] = Message;
}
else
{
cbpNDTStaffs.JSProperties["cpIsUpdated"] = "";
}
}
for (i = 0; i <= ChklstNDTStaffs.Items.Count - 1; i++)
{
string EmpIDAndName = string.Empty;
string EID = "";
if (ChklstNDTStaffs.Items[i].Selected==true)
{
EmpIDAndName = Convert.ToString(ChklstNDTStaffs.Items[i].Text);
EID = Convert.ToString(ChklstNDTStaffs.Items[i].Value);
Int64 ReturnValue = DataAccess.NDTDataAccess.UpdateNDTStaffs(EID, CurrentlyLoggedUserName);
if (ReturnValue > 0)
{
Message = "Selected NDT Staff(s) Removed Successfully.";
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.