473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Add a confirm box to a LinkButton in datagrid

Hi,

I have a LinkButton inside a datagrid, when this LinkButton is clicked, the
program deleete a record in database. I would like to add a confirmation on
client side. I know I can do Attributes.Add("onclick",...) to Buttons not in
datagrid. But how do I do it for LinkButton in datagrid?

TIA
Nov 19 '05 #1
1 1607
"Danny Ni" <dn*@yahoo.com> wrote in message
news:eT**************@TK2MSFTNGP09.phx.gbl...
I have a LinkButton inside a datagrid, when this LinkButton is clicked,
the
program deleete a record in database. I would like to add a confirmation
on
client side. I know I can do Attributes.Add("onclick",...) to Buttons not
in
datagrid. But how do I do it for LinkButton in datagrid?


public void dgrd_ItemCreated(Object sender, DataGridItemEventArgs e)
{
LinkButton cmdDelete;
if((e.Item.ItemType == ListItemType.Item)
|| (e.Item.ItemType == ListItemType.AlternatingItem)
|| (e.Item.ItemType == ListItemType.EditItem))
{
cmdDelete = (LinkButton)e.Item.Cells[0].Controls[0];
cmdDelete.Attributes.Add("onclick", "return confirm('Are you sure you
want to delete this record?');");
}
}

The above example assumes that your LinkButton is the first Control in the
first column of the datagrid - change the e.Item.Cells[0].Controls[0] values
accordingly if it is not.
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joe Finsterwald | last post by:
Recently I needed to add a confirm to a LinkButton that called a JavaScript function on success, and did nothing on failure. I found documentation on adding a confirm, but not on how to place a...
4
by: Calvin Lai | last post by:
Hi all, Does anyone know how I could add a confirm (client side) feature on those Delete Linkbutton in DataGrid? Thanks,
2
by: mark | last post by:
im having issues in creating a javascript confirm option on pressing a delete button in a datagrid - ive tried a few things but nothing seems to work (either crashes or does nothing) my codebehind...
1
by: Sandy | last post by:
I have a repeater which shows Group names. (Skip this part if you want rather irrelevant) The groups are ordered and formatted: Parent ---Child ------Grand Child (okay start reading again...
2
by: George Durzi | last post by:
I have to LinkButtons in a DataGrid, and each of them has a Command="Select" attribute set up. When either of hte LinkButton's is clicked, I want the proper row in the DataGrid to be selected, but...
3
by: Arne | last post by:
I have a delete column in a datagird. I would like to execute cmdDelete.Attributes.Add("onclick", "return confirm('Delete this record?');") somewhere. Where is the right place to put this code?
2
by: dddan | last post by:
Here's my code: <asp:LinkButton OnClick="DeleteFile" OnClientClick="if (!confirm ('Are you certain you want to delete this file?') ) return false;" runat="server" ID="DeleteButton">DELETE...
5
daJunkCollector
by: daJunkCollector | last post by:
What I am doing here should be obvious. I have a datagrid that displays data properly. I want to create a linkbutton within each row of the datagrid that toggles a label control in the same row...
2
by: RN1 | last post by:
I have a DataList which displays the first & last name of users as links (LinkButtons). When the links are clicked, 2 textboxes appear - one with the first name & the other with the last name - for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.