IT Community - Software Programming, Web Development and Technical Support

ListView server control in ASP.Net 3.5

This is a discussion on ListView server control in ASP.Net 3.5 within the Discussweb HQ forums, part of the The Lobby category; Display a warning message when the user clicks Delete in a ListView Control It will be always helpful to ask ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > The Lobby > Discussweb HQ

Register FAQ Members List Calendar Mark Forums Read

Reply
 
Thread Tools Display Modes
  #11  
Old 03-31-2008, 03:07 AM
S.Vinothkumar S.Vinothkumar is offline
D-Web Genius
 
Join Date: May 2007
Posts: 905
S.Vinothkumar is on a distinguished road
Wink Re: ListView server control in ASP.Net 3.5

Display a warning message when the user clicks Delete in a ListView Control


It will be always helpful to ask user before they actually delete the row from the ListView and eventually from the database. We could display a warning message whether they really intend to delete the row. If the reply is either yes or OK, then we could carry out with the actual removal of the rows from the database.

This can be done using the following technique:

During the ItemDataBound event, we can attach a client side event for each Delete Link in the ListView control.

Code:
protected void DataBoundList(Object sender, ListViewItemEventArgs e)
{
  if (e.Item.ItemType == ListViewItemType.DataItem)
  {
    LinkButton lnkDelete = (LinkButton)e.Item.FindControl("lnkDelete");
    if (lnkDelete != null)
    {
      lnkDelete.Attributes.Add("onclick",
        "return confirm('Are you sure you want to delete this author?');");
    }
  }
}
Clicking on the delete link will result in the following alert box. If the user clicks cancel, then the delete operation will not be carried out.
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server 2000 migration to SQL Server 2005 Collation Change - Method? arjkhanna Database Support 5 10-02-2009 09:58 PM
How to control the webcam using C#? kingmaker C# Programming 9 09-05-2009 02:57 AM
Showing the Image file thumbnail view in ListView control using VC++ 6.0 prabhat.singh C and C++ Programming 0 01-17-2008 09:53 PM
How do I get the value of a form control? itbarota HTML, CSS and Javascript Coding Techniques 2 10-26-2007 03:13 AM
use of Custom Control and User Control? a.deeban ASP and ASP.NET Programming 1 08-20-2007 07:25 AM


All times are GMT -7. The time now is 03:17 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0