Delete Button in GridView FooterTemplate

Discussion in 'ASP .Net' started by =?Utf-8?B?SmFzb25L?=, Aug 7, 2006.

  1. I would like to move the Delete button such that it displays one time in the
    footer row, rather than on every row. I've seen lots of questions asked on
    the subject around the net, but no answer that seems to solve the problem.

    I have tried a few things:
    - adding a button, setting it's command name to Delete. Problem with this
    is that the CommandArgument value does not get set to the SelectedIndex of
    the GridView. Instead it has the value of an empty string. I've tried
    binding the CommandArgument to the GridView.SelectedIndex, but that doesn't
    seem to work, and I later read that the footer might not support data binding.

    - writing javascript to this same button's "onClick" event, basically
    replicating the __doPostBack... call that can be found with each inline
    Delete button. This method regularly reloads the page, but for some reason I
    cannot determine, it only once in a while decides that it wants to delete the
    record. The rest of the time, nothing happens but a page reload.

    I'm using Visual Web Developer 2005 Express edition, if that makes any
    difference.

    As a last resort, I'm considering adding some code that will manually call a
    delete stored procedure, and manually rebind the GridView, but it was my hope
    that I could leverage the SqlDataSource control and GridView control to
    perform the work. However, if what I'm trying cannot be done, then I'll
    accept that answer, too.

    Any ideas, or questions for clarification (or code snippets)?

    Thanks in advance,

    Jason
     
    =?Utf-8?B?SmFzb25L?=, Aug 7, 2006
    #1
    1. Advertising

  2. OK...in a flash of brilliance, I decided to try and double click on the
    templated icon in the footer, and Visual Studio kindly generated an
    button_Click event for me. In this event I placed
    "GridView1.DeleteRow(GridView1.SelectedIndex)". Works perfectly every time.
    Nothing like stumbling on your own easy solution after banging your head
    against the wall for days.

    I'm going to get an ice pack now.

    "JasonK" wrote:

    > I would like to move the Delete button such that it displays one time in the
    > footer row, rather than on every row. I've seen lots of questions asked on
    > the subject around the net, but no answer that seems to solve the problem.
    >
    > I have tried a few things:
    > - adding a button, setting it's command name to Delete. Problem with this
    > is that the CommandArgument value does not get set to the SelectedIndex of
    > the GridView. Instead it has the value of an empty string. I've tried
    > binding the CommandArgument to the GridView.SelectedIndex, but that doesn't
    > seem to work, and I later read that the footer might not support data binding.
    >
    > - writing javascript to this same button's "onClick" event, basically
    > replicating the __doPostBack... call that can be found with each inline
    > Delete button. This method regularly reloads the page, but for some reason I
    > cannot determine, it only once in a while decides that it wants to delete the
    > record. The rest of the time, nothing happens but a page reload.
    >
    > I'm using Visual Web Developer 2005 Express edition, if that makes any
    > difference.
    >
    > As a last resort, I'm considering adding some code that will manually call a
    > delete stored procedure, and manually rebind the GridView, but it was my hope
    > that I could leverage the SqlDataSource control and GridView control to
    > perform the work. However, if what I'm trying cannot be done, then I'll
    > accept that answer, too.
    >
    > Any ideas, or questions for clarification (or code snippets)?
    >
    > Thanks in advance,
    >
    > Jason
     
    =?Utf-8?B?SmFzb25L?=, Aug 8, 2006
    #2
    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. Jorge Loaiza Arango

    Access to controls in <FooterTemplate>

    Jorge Loaiza Arango, Dec 21, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    636
    Jose Suero
    Dec 21, 2003
  2. =?Utf-8?B?bWFoc2E=?=

    how can I access to controls in footertemplate

    =?Utf-8?B?bWFoc2E=?=, Jul 9, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    347
    =?Utf-8?B?bWFoc2E=?=
    Jul 9, 2004
  3. Vishal

    Footertemplate is called twice?

    Vishal, Jan 12, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    345
    Scott Allen
    Jan 12, 2005
  4. Jeff
    Replies:
    0
    Views:
    369
  5. Andy B.
    Replies:
    3
    Views:
    1,294
    Vijay
    Jan 9, 2010
Loading...

Share This Page