Delete Button!!!

C

Child X

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
 
J

jm

Child said:
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=rowd...d=ie7&rls=com.microsoft:en-US&ie=utf8&oe=utf8

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

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top