Delete Button in GridView FooterTemplate

G

Guest

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
 
G

Guest

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.
 

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

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,807
Latest member
ryef

Latest Threads

Top