Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

OnItemCommand for deleting a row

This should work but i dont know why it's not.

I have a listview like this;
 
<asp:ListView ID="lvOutgoing" 
                 OnSelectedIndexChanging="lvOutgoing_SelectedIndexChanging"
                OnItemCommand =   "lvOutgoing_ItemCommand" 
                 
              runat="server">

Open in new window


This inside the listview;
<td><asp:LinkButton ID="EditButton" runat="Server" Text="Edit" CommandName="Select" /></td>
          <td style="text-align:center" width="60" align="center"><div class="delete_bookmark_icon"><asp:LinkButton Text="Delete"   CommandName="Delete" runat="server" ID="lbDelete"></asp:LinkButton> </div></td>

Open in new window


And this to delete:

 protected void lvOutgoing_ItemCommand(object sender, ListViewCommandEventArgs e)
    {

        if (e.CommandName == "Select")
        {
            Label lblPatientId = (Label)e.Item.FindControl("lblrowId");   
               ....
        }

        if (e.CommandName == "Delete")
        {
          Label lblPatientId = (Label)e.Item.FindControl("lblrowId");
           .....

       }

        
    }
          

Open in new window


But I get an error that onItemdeleting is not being handled. So, I added this:

OnItemDeleting=  "lvOutgoing_OnItemDeleting" 

Open in new window


And the event:
 protected void lvOutgoing_OnItemDeleting(object sender, ListViewDeleteEventArgs e)
    {
       }

Open in new window


But now I dont know how to find the row I click on. How can I do this?
ASKER CERTIFIED SOLUTION
Avatar of masterpass
masterpass
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial