Re: Delete Button!!!

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




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=rowdatabound+add+attributes+javascript&sourceid=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)");
// }

.



Relevant Pages

  • Delete Button!!!
    ... I have the following datagrid: ... What i want to acheive is attach a onclick javascript event on the delete ... button generated in the Grid. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How does ATTACH pass address of ECB to child?
    ... How does ATTACH pass address of ECB to child? ... was come up with example uses for compare&swap instruction ... ...
    (bit.listserv.ibm-main)
  • Re: How does ATTACH pass address of ECB to child?
    ... How does ATTACH pass address of ECB to child? ...
    (bit.listserv.ibm-main)
  • Re: newbie - simple Master/Details question
    ... I changed the way I handle my SQL, and made the child table's SQL statement ... fields being searched upon in the parent, don't occur in the child - it got ... In MSHFlexGrid, the only navigation was the "+" button, and the scroll ... I am trying to find a way of doing this in a single datagrid though, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: DataGrid sort
    ... I had high hopes for this solution, but the child table DataGrid remains unsorted. ... > DataView dv = cm.List; ... >> Normally I would set the DataGrid DataSource to default or custom DataView ...
    (microsoft.public.dotnet.framework.windowsforms)