Bug in DataGrid - ItemCommand event does not fire for ButtonColumnif ButtonType="PushButton"

N

Nick Gilbert

We have a Datagrid which contains a template column with a button in it,
as well as an actual button column. If either of the buttons are
clicked, the ItemCommand event does not fire.

If however, the ButtonType of the ButtonColumn is changed to
"LinkButton" instead of "PushButton", the event fires normally!

Why on earth is this happening? I presume this a bug in .NET? (We are
using 1.1 final).

<asp:DataGrid id="JobsDataGrid" runat="server"
AutoGenerateColumns="False"
DataKeyField="JobNumber" >
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button ID="RunJobButton" Runat="server"
CommandName="RunJob"
CommandArgument="1"
Text="Run Task 1" />
</ItemTemplate>

</asp:TemplateColumn>
<asp:ButtonColumn ButtonType="PushButton" CommandName="RunJob"
Text="Run Task 2" />
</Columns>
</asp:DataGrid>

Any ideas how to fix this would be appeciated.

Nick...
 
S

Sonali.NET[MVP]

You might not be handling PostBack in the Page Load
Try adding the statements
if not Page.IsPostback then
'your code
end if
 
J

Jeffrey Tan[MSFT]

Hi Nick,

I found that this post has been posted in several groups. I have added a
reply to you in microsoft.public.dotnet.framework.aspnet.datagridcontrol.
Please follow up there, I will work with you.
Thanks for your understanding,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top