Button in footer of datagrid not causing itemcommand event?

  • Thread starter Thread starter Utter Newbie
  • Start date Start date
U

Utter Newbie

Anyone know what could be the problem? I gave the button in the footer
a command name but when the button is clicked the datagrid_itemcommand
event is never fired (tracing it in the debugger)? It is strange...
All buttons in the item list work and cause the event... Just not my
footer button... I added the button in the footer template of the
template column in question.

<FooterTemplate>
<asp:Button id="btnAddCategory" CommandName="Insert"
runat="server" CssClass="button" Text="Add Category"
CausesValidation="false"></asp:Button>
</FooterTemplate>

Any ideas? Thanks.
 
Hi,

Why don't you simply attach a handler to the click event of the button?

Greetings
Martin
 
The headers and footers are not in the DataGridItemCollection. You'll
have to add an explicit handler as Martin suggested.
 
Made a newbie mistake (Hence my name). When I was testing I had my
poplulatedatagrid method in the page_load event. But I hadn't put it
in a if(!Page.IsPostBack)... So the button event was firing but my
datagrid was begin rewritten each time so the event was wiped out it
seems...

So it does work without having to attach a handler explicitly as long
as you have a commandname property set. Although I did try attaching
a handler explicitly as well but obviously same effect because it was
begin written over each time... Sorry for wasting peoples time. Thanks
for the suggestions though.. Might come in handy somewhere down the
line. :)
 
Back
Top