Solved

OnItemCommand for deleting a row

Posted on 2012-04-04
1
218 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Editing XSL files, 2 40
Please explain: Aspect Oriented Programming 2 83
New to Angular (read tutorial) - How do I bind to this table? 11 45
Jquey and footrable 2 34
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

930 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

9 Experts available now in Live!

Get 1:1 Help Now