@Blog.Author(Nandip Makwana) .LearningExperience(ASP.NET, ASP.NET MVC, IIS, jQuery & Technology Surrounding it...)

May 21, 2009 comment

Performing delete operation with client script confirmation in ASP .NET


THIS IS A2R (ANSWER TO READER) ARTICLE.
.
Hi Dorababu, you can follow one of following method to delete record from emp table.
.
I think asking employee id or name is not good thing instead you can populate dropdowncombo box with employee name or id or both and place one button for deleting employee. Clicking on that button will confirm from user and finally delete record if user wants!
.
OR
.
You can also fill gridview with employee id and name. Enable deleting in grid view.
.
I will explain this second method in which user confirmation is done with client script.
.
I have used northwind database from SQL Server 2000 in this example.
.
  • Take one gridview on webpage
  • Right click gridview and choose "Show smart tag".
  • In a choose datasource select new datasource
  • Configure datasource so it can display employee id and name.
  • Don't forget to GENERATE "DELETE SQL STATEMENT" by clicking advanced button at the time of configuration.
  • Now enable deleting in gridview.
  • That's all you have done.
  • To add user confirmation for deleting record apply following logic.
  • From the "Smart tag" menu of gridview click "edit columns…"
  • Now in selected field select "Delete" and click on "convert this field to templatefield".
  • Click Ok Button





  • Now open html markup for webpage.
  • Modify gridview markup as follow.
  • You can find that there are <asp:TemplateField> Tag inside gridview markup.
.
.
  • Now add the following attribute in the <asp:LinkButton> Tag of <ItemTemplate>.
  • OnClientClick="return confirm('DO YOU REALLY WANT TO DELETE?');"
  • Now whenever you click on "Delete" Link it Will ask for user confirmation and if user press ok then and then delete operation will be performed otherwise delete operation will be aborted.
.
comments powered by Disqus

Featured Content

Resources & Tools

About Nandip Makwana

Nandip Makwana is passionate about digital world and web. He completed his Masters in Computer Application in June 2011. Currently he is working as a Software Engineer. He has shown great promise and command over ASP.NET and technologies surrounding it during his academic years and professorial life...continue reading