OnItemCommand for deleting a row

Posted on 2012-04-04
Medium Priority
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" 
                OnItemCommand =   "lvOutgoing_ItemCommand" 

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?
Question by:Camillia
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 21

Accepted Solution

masterpass earned 2000 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


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

765 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