The more and more I use the GridView control, the more I end up writing my own
rather then using the DataBound columns because of the additional flexiblity you get when writing your own templates.
This time I ended up writing my own TemplateField because I need to add a confirm pop up to basically a “delete” command (it didn’t really delete the database record but in fact flagged it as a different type)… but you get the idea where this might come in handy. After all you don’t want users calling saying “Yeah, I just deleted something I didn’t mean to”. Instead you want to pop up a javascript box with a “Do you really want to do this…because I am not fixing it again!”
Unfortunetly the
doesn’t offer you an onClientClick
event, so this is my work around.
Here is the basic Javascript code to pop up a confirm button.
<SCRIPT LANGUAGE=”JavaScript”>
function confirmSubmit() {
var agree=confirm(“Do you really want to mark this prospect as in the database?”);
if (agree)
return true ;
else
return false ;
}
</SCRIPT>
Now in your GridView->Column Tag add a
and your onClientClick attribute. This will call your Javascript function above and display a confirm popup to your users. You also must define a onClick event that points to a function that you will need to create for the server side processing of this request.
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID=”btnCustomerExist”
text=”customer exist”
Runat=Server
OnClick=”CustomerAlreadyExist”
OnClientClick=”return confirmSubmit()”
Width=”100″ />
</ItemTemplate>
</asp:TemplateField>
If the user clicks “OK” on the popup, you will need to handle the server side processing. I tend to write my own Data Access layer to handle Selects and Deletes so for me it is pretty straight forward from here, I call a function and pass in the unique id from the database.
Public Sub CustomerAlreadyExist(ByVal sender As Object, ByVal e As EventArgs)
Dim ProspectID As Int32
Dim btnRemoveProspect As Button = CType(sender, Button)
Dim grdRow As GridViewRow = CType(btnRemoveProspect.Parent.Parent, GridViewRow)
‘Get ID
ProspectID = grdRow.Cells(0).Text
‘Instant Class
myAddProspect = New AddProspect()
‘Removes from Prospect Table
myAddProspect.RemoveFromDatabase(ProspectID)
‘Refresh Gridview
Page_Load(sender, e)
End Sub
The End Result
Of course this won’t stop everyone from accidentally deleting users but it will stop 9/10.
MyDrive Connect – Now you may TomTom Update using TomTom MyDrive Connect in Australia. TomTom Update, Register, Manage, Sync etc using TomTom Software Here
Garmin.com/express – Now Install Garmin Express in order to do Garmin Update at Garmin.com/express. Update, Register, Manage, install or Sync Garmin Express
Contact Write My Custom Essay via the 24-hour live chat. Our friendly customer service representatives will inform you about the various services and policies we offer. Furthermore, if you desire to place an order, all you have to do is say, “ Do my essay for me” and we will instantly initiate the job!
topping the trends
mcafee.com/activate – McAfee is an antivirus which is available worldwide for devices like Computer, Laptop or Smartphones, and McAfee is one of the best 10 Antivirus according to all reviews in last 10 years. McAfee Security is used to secure the devices from Trojans, Attacks, Malware or any other activities which may harm the devices or network.
Office.com/setup – Microsoft Office is world-renowned suite available for both personal and professional use. If you are one of Microsoft Office users then you would have an idea about the great services provided by them. Furthermore, it one of the oldest and still thriving suites in the market.
McAfee.com/activate – Visit the website in order to Get Started with the McAfee Activation or you may also contact us anytime at our Toll-free number to get help for McAfee Activate or Install.
Norton.com/setup – Setup your Norton subscription now with the help of this link. Let’s get started with your Norton Security today so just Activate Norton Subscription to enjoy the services.
McAfee.com/activate may be used in order to Activate McAfee Security. You may easily use the McAfee by going to the link and enter the 25 digit product key.
McAfee.com/Activate – McAfee Antivirus one of the popular Antivirus and Security System around the Globe. It helps many users to provide protection from the virus, trojan, spyware, and many similar threats. Ig you want to get started with McAfee then you have to go through the steps to McAfee.com/Activate. Secure your PC, Laptop, Tablet, and Smartphones with McAfee Antivirus and follow these to McAfee.com/Activate on your respective device.
norton.com/setup allows you to download and install the Norton Antivirus setup online on your device. You can manage your Norton product subscription and renewal from your Norton account. Norton provides you a Norton Utility tool to analyze and optimize your computer. Norton utility is a free tool which can be downloaded from the manufacturer website. It increased the boot speed and optimize the overall performance of the system.
Webroot.com/safe – It is very easy to install and use www.webroot.com/safe by following a few easy steps.In order to stop virus and worm to infect your device using Webroot, run setup and install it.
office.com/setup – We made Office Setup so easy that you may simply run the setup by visiting office.com/setup and enter the product key to get started with http://www.Office.com/setup.
norton.com/setup – In today’s world everything is online or in digital form which also has increased the risk of Viruses, Trojans, scams, data and identity theft, and Norton provides protection to your digital life from viruses and malware in a fraction of seconds. The Norton Product is better than any other anti-viruses as it monitors antimalware.
Thank you for sharing this useful information, I will regularly follow your blog
These are some important things. It has never been honored that it can be changed. To supply such tips, the responsibility of appreciation by a wide edge of centrality is for everyone.