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)");
// }