Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Delete Button!!!

Reply
Thread Tools

Delete Button!!!

 
 
Child X
Guest
Posts: n/a
 
      10-25-2006
Hi all,

I have the following datagrid:

<asp:GridView ID="gv" AutoGenerateColumns="False" DataKeyNames="ID"
runat="server">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID:" />
<asp:CommandField ShowDeleteButton="true" />
</Columns>
</asp:GridView>

What i want to acheive is attach a onclick javascript event on the delete
button generated in the Grid.

Can anyone give me an idea of how to do this in 2.0?

Would i use the OnRowDataBound event?

How would i access the button in each row via code?

Cheers,
Adam


 
Reply With Quote
 
 
 
 
jm
Guest
Posts: n/a
 
      10-25-2006

Child X wrote:
> Hi all,
>
> I have the following datagrid:
>
> <asp:GridView ID="gv" AutoGenerateColumns="False" DataKeyNames="ID"
> runat="server">
> <Columns>
> <asp:BoundField DataField="ID" HeaderText="ID:" />
> <asp:CommandField ShowDeleteButton="true" />
> </Columns>
> </asp:GridView>
>
> What i want to acheive is attach a onclick javascript event on the delete
> button generated in the Grid.
>
> Can anyone give me an idea of how to do this in 2.0?
>
> Would i use the OnRowDataBound event?
>
> How would i access the button in each row via code?
>
> Cheers,
> Adam


I would change it to a templatefield similar to the following and
access the control from my codefile as norma, adding attributes. I
would try your event for runtime script attributes add ons.
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="delete"
runat="server" OnClientClick="return confirm('Are you sure you want to
delete this record?');"
CommandName="Delete">Delete
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>


http://www.google.com/search?q=rowda...e=utf8&oe=utf8

http://www.codeproject.com/useritems...h_GridView.asp

// if (e.Row.RowType == DataControlRowType.DataRow)
// {
//((CheckBox)e.Row.FindControl("CheckMark")).Attribu tes.Add("onClick",
"ColorRow(this)");
// }

 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      10-25-2006
This article shows how you can confirm a delete in a datagrid:
http://www.dotnetjunkies.com/HowTo/1...EB07C94A8.dcik

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


"Child X" <> wrote in message
news:eh24KKH%...
> Hi all,
>
> I have the following datagrid:
>
> <asp:GridView ID="gv" AutoGenerateColumns="False" DataKeyNames="ID"
> runat="server">
> <Columns>
> <asp:BoundField DataField="ID" HeaderText="ID:" />
> <asp:CommandField ShowDeleteButton="true" />
> </Columns>
> </asp:GridView>
>
> What i want to acheive is attach a onclick javascript event on the delete
> button generated in the Grid.
>
> Can anyone give me an idea of how to do this in 2.0?
>
> Would i use the OnRowDataBound event?
>
> How would i access the button in each row via code?
>
> Cheers,
> Adam
>



 
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
To delete or not to delete? Lethal Computer Support 15 07-24-2005 11:47 PM
Can someone tell me why I can't delete this file? and why it blue screens WinXP Pro on delete? zZz Computer Support 1 01-12-2005 02:37 AM
Cannot Delete, (The Delete Key Won't Work) Lee Something Computer Support 13 10-15-2003 09:51 PM
Overloading new[] and delete[]: how do they vary from new and delete? HeroOfSpielburg C++ 1 08-06-2003 03:58 AM
delete on delete ! Sandeep Grover C++ 19 07-22-2003 10:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57