Solved

OnItemCommand for deleting a row

Posted on 2012-04-04
1
222 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
[X]
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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

724 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