Delete Button!!!

Discussion in 'ASP .Net' started by Child X, Oct 25, 2006.

  1. Child X

    Child X Guest

    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
     
    Child X, Oct 25, 2006
    #1
    1. Advertising

  2. Child X

    jm Guest

    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=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)");
    // }
     
    jm, Oct 25, 2006
    #2
    1. Advertising

  3. This article shows how you can confirm a delete in a datagrid:
    http://www.dotnetjunkies.com/HowTo/1E7FEE4A-795C-4D33-A135-843EB07C94A8.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
    >
     
    Steve C. Orr [MVP, MCSD], Oct 25, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sandeep Grover

    delete on delete !

    Sandeep Grover, Jul 12, 2003, in forum: C++
    Replies:
    19
    Views:
    639
    Chris \( Val \)
    Jul 22, 2003
  2. HeroOfSpielburg
    Replies:
    1
    Views:
    399
    Alf P. Steinbach
    Aug 6, 2003
  3. 0to60
    Replies:
    4
    Views:
    320
    Jerry Coffin
    Dec 19, 2003
  4. Mathieu Malaterre

    delete NULL, what about delete[] NULL

    Mathieu Malaterre, Aug 17, 2004, in forum: C++
    Replies:
    2
    Views:
    3,851
    Mathieu Malaterre
    Aug 17, 2004
  5. Jef Driesen
    Replies:
    1
    Views:
    512
    Gernot Frisch
    Jan 19, 2005
Loading...

Share This Page