SlideShare a Scribd company logo
1 of 2
Popup a ConfirmationBox before deleting arow in Gridview
1. Drag and Drop a Gridviewtothe WebForm.Attacha database table intothe GridView.The
followinglinkgivesdetailsof addingadatabase table intothe GridView,
https://www.slideshare.net/DharmaRaju2/how-to-add-sql-server-table-into-dot-net-web-
page-gridview
We can easilyadd ‘Delete’ buttonintothe GridView byselecting‘Enable Deleting’option
fromthe GridViewTasklist.But, the ‘Delete’buttonaddedbythismethodwon’taskfor
confirmationfromuserswhenitisclicked. Itsimplydeletesthe row whenwe press‘Delete’
button.But,by addingconfirmationoption,accidentaldeletionof rowsisprevented.
Here are the steps:
2. Clickon TaskButton  Clickon ‘AddNew Column’
3. SelectTemplate FieldfromFieldType
4. Enter a HeaderText,say‘Delete’.PressOKbutton
5. You can see Grid Viewwithanew column – ‘Delete’
6. Now,Switch the displayof the webpage to‘Source’mode. Findbelow line:
<asp:TemplateField HeaderText="Delete"></asp:TemplateField>
Breakthe above linesintotwoandinsertfew blanklines asshownbelow:
<asp:TemplateField HeaderText="Delete">
</asp:TemplateField>
7. Insertcode inbetweenthe above twolinesasshownbelow:
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:Button ID="btnDel" runat="server" Text="Delete"
CommandName="Delete" OnClientClick="return
confirm('Are you sure you want to delete this row?');" />
</ItemTemplate>
</asp:TemplateField>
8. Notice ‘Delete ‘Button’ insertedonall rowsof the GridView.
9. Openthe webpage ina browser.Clickondeletebutton. The systempromptsyoutoconfirm
whetheryoureallywantyoutodelete thatrow.Press OKto confirm.
10: Insteadof Button,youcan adda linkbuttonbychanging<Asp:Buttonto<asp:LinkButtonas
sownbelow:
<ItemTemplate>
<asp:LnkButton ID="btnDel" runat="server" Text="Delete"
CommandName="Delete" OnClientClick="return
confirm('Are you sure you want to delete the record?');" />
</ItemTemplate>
In my opinion, LinkButton looks better than Button in a GridView. See the Figure
above.
=== 0 ===

More Related Content

Similar to Popup confirmation for Delete Button in GridView

Lab StepsSTEP 1 Login Form1. In order to do this lab, we need.docx
Lab StepsSTEP 1 Login Form1. In order to do this lab, we need.docxLab StepsSTEP 1 Login Form1. In order to do this lab, we need.docx
Lab StepsSTEP 1 Login Form1. In order to do this lab, we need.docx
smile790243
 

Similar to Popup confirmation for Delete Button in GridView (20)

Grid view control
Grid view controlGrid view control
Grid view control
 
Grid Vew Control VB
Grid Vew Control VBGrid Vew Control VB
Grid Vew Control VB
 
Qlikview Quick Start
Qlikview Quick StartQlikview Quick Start
Qlikview Quick Start
 
Bootstrap with liferay
Bootstrap with liferayBootstrap with liferay
Bootstrap with liferay
 
Grid View Control CS
Grid View Control CSGrid View Control CS
Grid View Control CS
 
Chapter12 (1)
Chapter12 (1)Chapter12 (1)
Chapter12 (1)
 
Chapter 16
Chapter 16Chapter 16
Chapter 16
 
IntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdfIntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdf
 
IntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdfIntoTheNebulaArticle.pdf
IntoTheNebulaArticle.pdf
 
SAP HANA -Analytic view creation
SAP HANA -Analytic view creationSAP HANA -Analytic view creation
SAP HANA -Analytic view creation
 
Creating a dot netnuke
Creating a dot netnukeCreating a dot netnuke
Creating a dot netnuke
 
How to create drill down dashboard
How to create drill down dashboardHow to create drill down dashboard
How to create drill down dashboard
 
Quick View For Magento 2
Quick View For Magento 2 Quick View For Magento 2
Quick View For Magento 2
 
IBM developerWorks Cloud Trial – 90 days
IBM developerWorks Cloud Trial – 90 daysIBM developerWorks Cloud Trial – 90 days
IBM developerWorks Cloud Trial – 90 days
 
Lab StepsSTEP 1 Login Form1. In order to do this lab, we need.docx
Lab StepsSTEP 1 Login Form1. In order to do this lab, we need.docxLab StepsSTEP 1 Login Form1. In order to do this lab, we need.docx
Lab StepsSTEP 1 Login Form1. In order to do this lab, we need.docx
 
Journey to Azure Sentinel
Journey to Azure SentinelJourney to Azure Sentinel
Journey to Azure Sentinel
 
Database development connection steps
Database development connection stepsDatabase development connection steps
Database development connection steps
 
Hands on With Advanced Data Grid
Hands on With Advanced Data GridHands on With Advanced Data Grid
Hands on With Advanced Data Grid
 
Database Connection
Database ConnectionDatabase Connection
Database Connection
 
GWT training session 2
GWT training session 2GWT training session 2
GWT training session 2
 

More from Dharma Raju (6)

Master slave control in gridview
Master   slave control in gridviewMaster   slave control in gridview
Master slave control in gridview
 
Change row colour based on some condition
Change row colour based on some conditionChange row colour based on some condition
Change row colour based on some condition
 
Windows Communication Foundation (WCF) programming using Visual Studio
Windows Communication Foundation (WCF) programming using Visual StudioWindows Communication Foundation (WCF) programming using Visual Studio
Windows Communication Foundation (WCF) programming using Visual Studio
 
Internal tables in sap
Internal tables in sapInternal tables in sap
Internal tables in sap
 
Govina haadu
Govina haaduGovina haadu
Govina haadu
 
Coffee
CoffeeCoffee
Coffee
 

Recently uploaded

一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理
A
 
一比一原版(Design毕业证书)新加坡科技设计大学毕业证原件一模一样
一比一原版(Design毕业证书)新加坡科技设计大学毕业证原件一模一样一比一原版(Design毕业证书)新加坡科技设计大学毕业证原件一模一样
一比一原版(Design毕业证书)新加坡科技设计大学毕业证原件一模一样
AS
 
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
AS
 
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
c6eb683559b3
 
一比一原版(Polytechnic毕业证书)新加坡理工学院毕业证原件一模一样
一比一原版(Polytechnic毕业证书)新加坡理工学院毕业证原件一模一样一比一原版(Polytechnic毕业证书)新加坡理工学院毕业证原件一模一样
一比一原版(Polytechnic毕业证书)新加坡理工学院毕业证原件一模一样
AS
 
一比一原版美国北卡罗莱纳大学毕业证如何办理
一比一原版美国北卡罗莱纳大学毕业证如何办理一比一原版美国北卡罗莱纳大学毕业证如何办理
一比一原版美国北卡罗莱纳大学毕业证如何办理
A
 
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
Fir
 
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
Fi
 
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
Fir
 
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
AS
 
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
musaddumba454
 
一比一原版英国创意艺术大学毕业证如何办理
一比一原版英国创意艺术大学毕业证如何办理一比一原版英国创意艺术大学毕业证如何办理
一比一原版英国创意艺术大学毕业证如何办理
AS
 

Recently uploaded (20)

[Hackersuli] Élő szövet a fémvázon: Python és gépi tanulás a Zeek platformon
[Hackersuli] Élő szövet a fémvázon: Python és gépi tanulás a Zeek platformon[Hackersuli] Élő szövet a fémvázon: Python és gépi tanulás a Zeek platformon
[Hackersuli] Élő szövet a fémvázon: Python és gépi tanulás a Zeek platformon
 
SOC Analyst Guide For Beginners SOC analysts work as members of a managed sec...
SOC Analyst Guide For Beginners SOC analysts work as members of a managed sec...SOC Analyst Guide For Beginners SOC analysts work as members of a managed sec...
SOC Analyst Guide For Beginners SOC analysts work as members of a managed sec...
 
一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理一比一原版布兰迪斯大学毕业证如何办理
一比一原版布兰迪斯大学毕业证如何办理
 
一比一原版(Design毕业证书)新加坡科技设计大学毕业证原件一模一样
一比一原版(Design毕业证书)新加坡科技设计大学毕业证原件一模一样一比一原版(Design毕业证书)新加坡科技设计大学毕业证原件一模一样
一比一原版(Design毕业证书)新加坡科技设计大学毕业证原件一模一样
 
VIP ℂall Girls Bangalore 8250077686 WhatsApp: Me All Time Serviℂe Available D...
VIP ℂall Girls Bangalore 8250077686 WhatsApp: Me All Time Serviℂe Available D...VIP ℂall Girls Bangalore 8250077686 WhatsApp: Me All Time Serviℂe Available D...
VIP ℂall Girls Bangalore 8250077686 WhatsApp: Me All Time Serviℂe Available D...
 
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
原版定制(LBS毕业证书)英国伦敦商学院毕业证原件一模一样
 
APNIC Updates presented by Paul Wilson at CaribNOG 27
APNIC Updates presented by Paul Wilson at  CaribNOG 27APNIC Updates presented by Paul Wilson at  CaribNOG 27
APNIC Updates presented by Paul Wilson at CaribNOG 27
 
HUMANIZE YOUR BRAND - FREE E-WORKBOOK Download Now
HUMANIZE YOUR BRAND - FREE E-WORKBOOK Download NowHUMANIZE YOUR BRAND - FREE E-WORKBOOK Download Now
HUMANIZE YOUR BRAND - FREE E-WORKBOOK Download Now
 
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
一比一原版(NYU毕业证书)美国纽约大学毕业证学位证书
 
一比一原版(Polytechnic毕业证书)新加坡理工学院毕业证原件一模一样
一比一原版(Polytechnic毕业证书)新加坡理工学院毕业证原件一模一样一比一原版(Polytechnic毕业证书)新加坡理工学院毕业证原件一模一样
一比一原版(Polytechnic毕业证书)新加坡理工学院毕业证原件一模一样
 
I’ll See Y’All Motherfuckers In Game 7 Shirt
I’ll See Y’All Motherfuckers In Game 7 ShirtI’ll See Y’All Motherfuckers In Game 7 Shirt
I’ll See Y’All Motherfuckers In Game 7 Shirt
 
一比一原版美国北卡罗莱纳大学毕业证如何办理
一比一原版美国北卡罗莱纳大学毕业证如何办理一比一原版美国北卡罗莱纳大学毕业证如何办理
一比一原版美国北卡罗莱纳大学毕业证如何办理
 
The Rise of Subscription-Based Digital Services.pdf
The Rise of Subscription-Based Digital Services.pdfThe Rise of Subscription-Based Digital Services.pdf
The Rise of Subscription-Based Digital Services.pdf
 
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
一比一定制(USC毕业证书)美国南加州大学毕业证学位证书
 
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
一比一原版(Soton毕业证书)南安普顿大学毕业证原件一模一样
 
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
一比一原版(TRU毕业证书)温哥华社区学院毕业证如何办理
 
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
一比一原版(Dundee毕业证书)英国爱丁堡龙比亚大学毕业证如何办理
 
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
100^%)( POLOKWANE))(*((+27838792658))*))௹ )Abortion Pills for Sale in Sibasa,...
 
一比一原版英国创意艺术大学毕业证如何办理
一比一原版英国创意艺术大学毕业证如何办理一比一原版英国创意艺术大学毕业证如何办理
一比一原版英国创意艺术大学毕业证如何办理
 
Dan Quinn Commanders Feather Dad Hat Hoodie
Dan Quinn Commanders Feather Dad Hat HoodieDan Quinn Commanders Feather Dad Hat Hoodie
Dan Quinn Commanders Feather Dad Hat Hoodie
 

Popup confirmation for Delete Button in GridView

  • 1. Popup a ConfirmationBox before deleting arow in Gridview 1. Drag and Drop a Gridviewtothe WebForm.Attacha database table intothe GridView.The followinglinkgivesdetailsof addingadatabase table intothe GridView, https://www.slideshare.net/DharmaRaju2/how-to-add-sql-server-table-into-dot-net-web- page-gridview We can easilyadd ‘Delete’ buttonintothe GridView byselecting‘Enable Deleting’option fromthe GridViewTasklist.But, the ‘Delete’buttonaddedbythismethodwon’taskfor confirmationfromuserswhenitisclicked. Itsimplydeletesthe row whenwe press‘Delete’ button.But,by addingconfirmationoption,accidentaldeletionof rowsisprevented. Here are the steps: 2. Clickon TaskButton  Clickon ‘AddNew Column’ 3. SelectTemplate FieldfromFieldType 4. Enter a HeaderText,say‘Delete’.PressOKbutton 5. You can see Grid Viewwithanew column – ‘Delete’ 6. Now,Switch the displayof the webpage to‘Source’mode. Findbelow line: <asp:TemplateField HeaderText="Delete"></asp:TemplateField> Breakthe above linesintotwoandinsertfew blanklines asshownbelow: <asp:TemplateField HeaderText="Delete"> </asp:TemplateField> 7. Insertcode inbetweenthe above twolinesasshownbelow: <asp:TemplateField HeaderText="Delete"> <ItemTemplate> <asp:Button ID="btnDel" runat="server" Text="Delete" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete this row?');" /> </ItemTemplate> </asp:TemplateField> 8. Notice ‘Delete ‘Button’ insertedonall rowsof the GridView. 9. Openthe webpage ina browser.Clickondeletebutton. The systempromptsyoutoconfirm whetheryoureallywantyoutodelete thatrow.Press OKto confirm.
  • 2. 10: Insteadof Button,youcan adda linkbuttonbychanging<Asp:Buttonto<asp:LinkButtonas sownbelow: <ItemTemplate> <asp:LnkButton ID="btnDel" runat="server" Text="Delete" CommandName="Delete" OnClientClick="return confirm('Are you sure you want to delete the record?');" /> </ItemTemplate> In my opinion, LinkButton looks better than Button in a GridView. See the Figure above. === 0 ===