Solved

OnItemCommand for deleting a row

Posted on 2012-04-04
1
217 Views
Last Modified: 2012-04-05
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?
0
Comment
Question by:Camillia
1 Comment
 
LVL 21

Accepted Solution

by:
masterpass earned 500 total points
ID: 37809477
you can get it like this

protected void lvOutgoing_OnItemDeleting(object sender, ListViewDeleteEventArgs e)
{
var item = lvOutgoing.Items[e.ItemIndex];
//do what ever you want with this item
}

Open in new window

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now