Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Delete Button in GridView FooterTemplate

Reply
Thread Tools

Delete Button in GridView FooterTemplate

 
 
=?Utf-8?B?SmFzb25L?=
Guest
Posts: n/a
 
      08-07-2006
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmFzb25L?=
Guest
Posts: n/a
 
      08-07-2006
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FormView.FooterTemplate and button clicks Andy B. ASP .Net 3 01-09-2010 02:14 PM
<GridView> FooterTemplate and no rows, problem Jeff ASP .Net 0 11-04-2008 08:49 AM
Footertemplate is called twice? Vishal ASP .Net 1 01-12-2005 08:16 PM
how can I access to controls in footertemplate =?Utf-8?B?bWFoc2E=?= ASP .Net 0 07-09-2004 07:56 PM
Access to controls in <FooterTemplate> Jorge Loaiza Arango ASP .Net 1 12-21-2003 06:31 PM



Advertisments