Button in footer of datagrid not causing itemcommand event?

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.
 
M

Martin Dechev

Hi,

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

Greetings
Martin
 
S

Scott Allen

The headers and footers are not in the DataGridItemCollection. You'll
have to add an explicit handler as Martin suggested.
 
U

Utter Newbie

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. :)
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top