Adding Checkbox in asp.net Listview control to allow multiple delete

10,515

Add Checkbox in markup

<asp:CheckBox ID="ChkSelect" runat="server" />

code behind as follows:

Dim ChkSelect As CheckBox = Nothing
Dim ListItem As ListViewDataItem = Nothing
Dim ItemList As List(Of Person) = New List(Of Person)
Dim Item As Person= Nothing

    For Each ListItem In MyDataList.Items
        ChkSelect = ListItem.FindControl("ChkSelect")
        If ChkSelect.Checked Then

            Dim UIN As Integer = _
              MyDataList.DataKeys(ListItem.DisplayIndex).Value.ToString()
            Item = Persons.GetData(UIN)
            Item.Deleted = True
            ItemList.Add(Item)

        End If
    Next
    Data = Persons.UpdateBulk(ItemList)
    If Data = True Then
        BindMyData()
    End If
Share:
10,515
KoolKabin
Author by

KoolKabin

A freelance web developer Websites: 1.) http://biotechx.com 2.) http://highcountrytrekking.com 3.) http://firante.com 4.) http://himalayanencounters.com 5.) http://ajisai.edu.np 6.) http://environmentnepal.info/test 7.) http://treknepal.au 8.) http://sunshinetrekking.com 9.) http://taverntrove.com 10.) http://trekkingandtoursnepal.com 11.) http://outsourcingnepal.com

Updated on June 04, 2022

Comments

  • KoolKabin
    KoolKabin almost 2 years

    I am trying to display checkboxes in front of every row in list view. So that after selecting the desired checkboxes user clicks on delete button and we should delete that records.

    but how can it be done?