Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Confirm a delete in a Datagrid

Reply
Thread Tools

Confirm a delete in a Datagrid

 
 
=?Utf-8?B?QXJuZQ==?=
Guest
Posts: n/a
 
      04-28-2005
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?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGF2ZQ==?=
Guest
Posts: n/a
 
      04-28-2005
Try the ItemDataBound event for the grid...

private void dgGrid1_ItemDataBound(Object sender, DataGridItemEventArgs e)
{

if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem )
{
LinkButton lbtnDelete = e.Item.FindControl("lbtnDelete") as LinkButton;
lbtnDelete.Attributes.Add("onclick", "return confirm('Delete this record?')");
}
}

"Arne" wrote:

> 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?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?QXJuZQ==?=
Guest
Posts: n/a
 
      04-28-2005
That doesn't work for a linkbutton with an autopostback.

"Dave" wrote:

> Try the ItemDataBound event for the grid...
>
> private void dgGrid1_ItemDataBound(Object sender, DataGridItemEventArgs e)
> {
>
> if (e.Item.ItemType == ListItemType.Item ||
> e.Item.ItemType == ListItemType.AlternatingItem )
> {
> LinkButton lbtnDelete = e.Item.FindControl("lbtnDelete") as LinkButton;
> lbtnDelete.Attributes.Add("onclick", "return confirm('Delete this record?')");
> }
> }
>
> "Arne" wrote:
>
> > 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?

 
Reply With Quote
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      04-28-2005
I believe this article contains your solution:
http://www.dotnetjunkies.com/HowTo/1...EB07C94A8.dcik

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"Arne" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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?



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid client-side confirm delete window - why does this work? =?iso-8859-1?B?UultaQ==?= ASP .Net 7 10-26-2005 08:46 PM
Confirm Delete in DataGrid Amelyan ASP .Net Web Controls 1 04-30-2005 06:50 PM
Re:how i make a window confirm to delete at datagrid? Saravana ASP .Net 1 10-04-2004 03:27 PM
how i make a window confirm to delete at datagrid? Dexter ASP .Net 2 10-03-2004 10:43 PM
confirm box when clicking Delete Linkbutton in DG Calvin Lai ASP .Net 4 02-04-2004 03:03 PM



Advertisments