Solved

asp.net gridview onclientclick parameter

Posted on 2016-08-22
3
33 Views
Last Modified: 2016-08-23
I have a gridview with a column containing an asplink button which will delete the record in that row.  I could not figure out how to do it in the code behind so here is what it looks like in the page code:

<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
                            CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this Employee?');"></asp:LinkButton>

I would like to add some more detail (a column or two in the gridview) to the message such as the employee first and last name.
0
Comment
Question by:schwientekd
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
Lokesh B R earned 500 total points
Comment Utility
Hi,

Check the sample here
0
 

Author Comment

by:schwientekd
Comment Utility
That looks like a great example and I can get the pop up message to appear but I cannot get it to pass the parameter.  I have tried this in a gridview which has textbox item template fields and also label fields.  Can it be that this method does not work with template fields?  This is the line which should be retrieving the parameter and I think is the problem I am running into.  Does it look correct?

Dim id As String = e.Row.Cells(3).Text
0
 

Author Comment

by:schwientekd
Comment Utility
I changed the line above to this and it worked.

Dim id As String = TryCast(e.Row.FindControl("textBox1"), TextBox).Text()
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now