473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

datagrid OnItemCommand handler not executing

I have an asp.net page on which I have a datagrid. The datagrid works
exactly as I want up to this point: I want to have a pushbutton on the
datagrid that will cause the selected row to a different table. There are
many examples of this, but I can't seem to get the OnItemCommand handler to
fire.

The page is called DraftHitters.aspx and has the C# code in
DraftHitters.aspx.cs. Everything _else_ works great.

Here are some snippets:

In DraftHitters.aspx

<%@ Page language="c#" Codebehind="DraftHitters.aspx.cs"
AutoEventWireup="false" Inherits="Baseball.BatterDraft" %>

<asp:datagrid id=gridResults ... runat="server" ... OnItemCommand="Draft"
.... AutoGenerateColumns="False" ...>
....
<Columns>
<asp:ButtonColumn Text="Draft" ButtonType="PushButton"
CommandName="Draft"></asp:ButtonColumn>
....
</Columns>
....
</asp:datagrid>
In DraftHitters.aspx.cs

public void Draft(object Sender,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int i;
i=5;
}

I can set a breakpoint on the i=5 line and run with debugging; the
breakpoint is never reached. I can debug the rest of the page, so I know I
have debugging set up properly. The reason that Draft is such a useless
function is that I just want to get the thing to run, then obviously I'll
put real, useful code in it. i=5 is the most trivial line I could think of
that I could set a breakpoing on.

It seems like I am missing something about setting up the handler. Most of
the examples I've seen put the handler in a <script> tag on the aspx page; I
don't want to do that.

Thanks!
Nov 18 '05 #1
1 1811
Hi,

There are two ways to attach event handler to event:

1) Using the onXXX attribute (as you do).
2) Using control event in code behind to add event handler to event
delegate. The easy way to do it is to use properties window of the grid,
select the events tab (the light) and double click on ItemCommand.

I'm using both of them without any problems, try to use the second
option. But I really can’t figure out way the first option doesn’t work
for you (I even try it on simple page).

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stanley J Mroczek | last post by:
I am trying to load a dropdownlist in VB when the edit is clicked in a datagrid. How do i call Sub loaddd to load the dropdownlist <asp:TemplateColumn runat="server" HeaderText="Id Type Option"...
1
by: | last post by:
When I defined Sub OnItemCommand() Action XXX XXX End Sub If there are any method to stop raising the OnItemCommand when I click a button? ( I don'w want to edit the code inside
4
by: News | last post by:
I have a page with many controls. Among these controls there is a table which is a datagrid with nested repeater inside. My problem is that I can not use DataGridCommandEventArgs to get datagrid...
2
by: Syed Sami R. Shah | last post by:
hi all, i am having problem with using itemcommand of datagrid by way of asp:image button. i have put an image button in a datagrid item template and have set CommandName="DeleteRecord" and have...
1
by: Joe | last post by:
Hi, I have form with datagrid. This is what my form tag looks like, <form runat="server"> <asp:label runat="server" id="lblMessage" /> <asp:DataGrid runat="server" id="articleList"...
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
0
by: LeAnne | last post by:
In my ASPX page, I populate the GRID when the user selects an item in the dropdown list. Thus, the data is fetched and the data grid DataBind() method is executed in the PostBack (i.e. IsPostBack...
1
by: rp13 | last post by:
Hi, I am using a asp:datagrid which is editable. Though I have handlers wired to my edit, update & cancel events, some how when i click on the edit button nothing happens. The edit template...
0
by: Rocky | last post by:
Dear ALL, I am facing a bit problem in DATAGRID. so may be you guys can help me out. Actually on a DataGrid I am having following controls: 1) 2 DropDown Menu 2) 1 Text Box 3) 1 ADD Button 4)...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.