R
Rick White
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!
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!