简体   繁体   English

基于Asp.net C#中的selecteditem,不会删除AspxCheckbox列表中的所选项目

[英]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.

相关问题 如何在asp.net C#Web窗体应用程序中基于下拉列表的选定值填充文本框? - How to populate a textbox based on the selected value of a dropdown list in an asp.net c# web forms application? 在下拉列表中列出大量项目asp.net C# - list large numbers of items in dropdown asp.net c# 在ASP.NET C#中显示项目列表 - Displaying List of items in asp.net C# 如何根据从下拉列表中选择的内容(ASP.NET中的C#)更改标签的输出 - How can I change the output of a label, based on what's selected from a dropdown list (C# in ASP.NET) 如何从CheckBoxList获取选定项并将其转移到另一页ASP.Net C# - How to get selected items from a CheckBoxList and transfer it to another page ASP.Net C# 如何在 ASP.NET C# 中使用 foreach 获取 CheckBoxList 中所选项目的值? - How to get values of selected items in CheckBoxList with foreach in ASP.NET C#? 如何使用引导选择列表显示带有所选项目的消息 C# ASP .NET - How to show a message with the selected items with a Bootstrap Select List C# ASP .NET 将选定的多个列表框项目的值存储在asp.net - store selected value of multiple list box items in asp.net C#ASP.Net-如何显示基于DropDownList中选定值的文本框 - C# ASP.Net - How to Display TextBox Based on Selected Value in DropDownList 拖放列表项后获得列表顺序asp.net C# - Get list order after dragging and dropping list items asp.net c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM