EditCommandColumn not genereting correct events

Discussion in 'ASP .Net' started by Jaime, May 14, 2005.

  1. Jaime

    Jaime Guest

    Hi all,

    I have a datagrid with 2 databound columns and one EditCommandColumn, now
    when I press the edit link, the correct OnEditCommand event is generated and
    my user defined function is called (I'm sepcifying the name of the function
    in the datagrid OnEditCommand="OnEdit"). Now the problem is that when I
    press the update linkbutton, the datagrid calls my OnEdit function and when
    I press the cancel linkbutton, the datagrid calls nothing in my code and it
    cancels the edit mode.... One more thing, every event, the OnCommand handler
    is called except the OnCancel...

    Any help?

    Here's the definiction of the datagrid

    <asp:DataGrid ID="CuentasDG"
    HorizontalAlign="Center"
    AutoGenerateColumns="False"
    CellPadding="3"
    OnUpdateCommand="Cuentas_OnUpdate"
    OnCancelCommand="Cuentas_OnCancel"
    OnItemDataBound="Cuentas_OnItemDataBound"
    OnEditCommand="Cuentas_OnEdit"
    OnItemCommand="Cuentas_OnCommand"
    Runat="server" >

    And each Cuentas_On... is defined as:
    protected void Cuentas_OnEdit( object sender, DataGridCommandEventArgs e )

    protected void Cuentas_OnUpdate( object sender, DataGridCommandEventArgs e )

    protected void Cuentas_OnCancel( object sender, DataGridCommandEventArgs e )

    protected void Cuentas_OnCommand( object sender, DataGridCommandEventArgs
    e )
     
    Jaime, May 14, 2005
    #1
    1. Advertising

  2. every time itemcommand is called but u can control flow by checkin
    commandname identifies command. And the other question,
    Are u sure you give true command names for link buttons causes datagrid
    events ???

    --

    Thanks,
    Yunus Emre ALPÖZEN
    BSc, MCAD.NET

    "Jaime" <j@j> wrote in message news:...
    > Hi all,
    >
    > I have a datagrid with 2 databound columns and one EditCommandColumn, now
    > when I press the edit link, the correct OnEditCommand event is generated
    > and my user defined function is called (I'm sepcifying the name of the
    > function in the datagrid OnEditCommand="OnEdit"). Now the problem is that
    > when I press the update linkbutton, the datagrid calls my OnEdit function
    > and when I press the cancel linkbutton, the datagrid calls nothing in my
    > code and it cancels the edit mode.... One more thing, every event, the
    > OnCommand handler is called except the OnCancel...
    >
    > Any help?
    >
    > Here's the definiction of the datagrid
    >
    > <asp:DataGrid ID="CuentasDG"
    > HorizontalAlign="Center"
    > AutoGenerateColumns="False"
    > CellPadding="3"
    > OnUpdateCommand="Cuentas_OnUpdate"
    > OnCancelCommand="Cuentas_OnCancel"
    > OnItemDataBound="Cuentas_OnItemDataBound"
    > OnEditCommand="Cuentas_OnEdit"
    > OnItemCommand="Cuentas_OnCommand"
    > Runat="server" >
    >
    > And each Cuentas_On... is defined as:
    > protected void Cuentas_OnEdit( object sender, DataGridCommandEventArgs e )
    >
    > protected void Cuentas_OnUpdate( object sender, DataGridCommandEventArgs
    > e )
    >
    > protected void Cuentas_OnCancel( object sender, DataGridCommandEventArgs
    > e )
    >
    > protected void Cuentas_OnCommand( object sender, DataGridCommandEventArgs
    > e )
    >
    >
    >
    >
    >
    >
     
    Yunus Emre ALPÖZEN [MCAD.NET], May 14, 2005
    #2
    1. Advertising

  3. Jaime

    Elton W Guest

    It seems that the viewstate of the datagrid is false.
    Disabled viewstate often causes the datagrid not work
    properly.

    HTH

    Elton Wang



    >-----Original Message-----
    >Hi all,
    >
    >I have a datagrid with 2 databound columns and one

    EditCommandColumn, now
    >when I press the edit link, the correct OnEditCommand

    event is generated and
    >my user defined function is called (I'm sepcifying the

    name of the function
    >in the datagrid OnEditCommand="OnEdit"). Now the problem

    is that when I
    >press the update linkbutton, the datagrid calls my OnEdit

    function and when
    >I press the cancel linkbutton, the datagrid calls nothing

    in my code and it
    >cancels the edit mode.... One more thing, every event,

    the OnCommand handler
    >is called except the OnCancel...
    >
    >Any help?
    >
    >Here's the definiction of the datagrid
    >
    > <asp:DataGrid ID="CuentasDG"
    > HorizontalAlign="Center"
    > AutoGenerateColumns="False"
    > CellPadding="3"
    > OnUpdateCommand="Cuentas_OnUpdate"
    > OnCancelCommand="Cuentas_OnCancel"
    > OnItemDataBound="Cuentas_OnItemDataBound"
    > OnEditCommand="Cuentas_OnEdit"
    > OnItemCommand="Cuentas_OnCommand"
    > Runat="server" >
    >
    >And each Cuentas_On... is defined as:
    >protected void Cuentas_OnEdit( object sender,

    DataGridCommandEventArgs e )
    >
    >protected void Cuentas_OnUpdate( object sender,

    DataGridCommandEventArgs e )
    >
    >protected void Cuentas_OnCancel( object sender,

    DataGridCommandEventArgs e )
    >
    >protected void Cuentas_OnCommand( object sender,

    DataGridCommandEventArgs
    >e )
    >
    >
    >
    >
    >
    >
    >.
    >
     
    Elton W, May 14, 2005
    #3
  4. Jaime

    Jaime Guest

    Hi,

    Well actually I'm using

    <asp:EditCommandColumn EditText="Edit" CancelText="Cancel"
    UpdateText="Update" HeaderText="Edit" />

    to generate the linkbuttons....

    I've some more details....

    I'm using my own page template framework and this is what seems to be
    causing the problem, but I can't figure out why. my template framework is
    something like:

    public class BasePage : System.Web.Ui.Page
    {
    public BasePage()
    {}

    protected override void OnLoad(EventArgs e)
    {
    this.Controls.AddAt( 0, LoadControl( "Header.ascx" ) );
    base.OnLoad( e );
    this.Controls.Add( LoadControl( "Footer.ascx: ) );
    }
    }

    and the derived page is

    public class MyPage : BasePage
    {
    private void Page_Load(...)
    {
    if( !IsPostBack )
    BindData()
    }

    protected BindData()
    {
    // get the data from the database
    }

    public void OnUpdate(...)
    {
    // this one never gets called
    }
    }


    "Yunus Emre ALPÖZEN [MCAD.NET]" <> wrote in message
    news:...
    > every time itemcommand is called but u can control flow by checkin
    > commandname identifies command. And the other question,
    > Are u sure you give true command names for link buttons causes datagrid
    > events ???
    >
    > --
    >
    > Thanks,
    > Yunus Emre ALPÖZEN
    > BSc, MCAD.NET
    >
    > "Jaime" <j@j> wrote in message
    > news:...
    >> Hi all,
    >>
    >> I have a datagrid with 2 databound columns and one EditCommandColumn, now
    >> when I press the edit link, the correct OnEditCommand event is generated
    >> and my user defined function is called (I'm sepcifying the name of the
    >> function in the datagrid OnEditCommand="OnEdit"). Now the problem is that
    >> when I press the update linkbutton, the datagrid calls my OnEdit function
    >> and when I press the cancel linkbutton, the datagrid calls nothing in my
    >> code and it cancels the edit mode.... One more thing, every event, the
    >> OnCommand handler is called except the OnCancel...
    >>
    >> Any help?
    >>
    >> Here's the definiction of the datagrid
    >>
    >> <asp:DataGrid ID="CuentasDG"
    >> HorizontalAlign="Center"
    >> AutoGenerateColumns="False"
    >> CellPadding="3"
    >> OnUpdateCommand="Cuentas_OnUpdate"
    >> OnCancelCommand="Cuentas_OnCancel"
    >> OnItemDataBound="Cuentas_OnItemDataBound"
    >> OnEditCommand="Cuentas_OnEdit"
    >> OnItemCommand="Cuentas_OnCommand"
    >> Runat="server" >
    >>
    >> And each Cuentas_On... is defined as:
    >> protected void Cuentas_OnEdit( object sender, DataGridCommandEventArgs
    >> e )
    >>
    >> protected void Cuentas_OnUpdate( object sender, DataGridCommandEventArgs
    >> e )
    >>
    >> protected void Cuentas_OnCancel( object sender, DataGridCommandEventArgs
    >> e )
    >>
    >> protected void Cuentas_OnCommand( object sender, DataGridCommandEventArgs
    >> e )
    >>
    >>
    >>
    >>
    >>
    >>

    >
    >
     
    Jaime, May 14, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick
    Replies:
    1
    Views:
    488
    Richard Ryerson
    Feb 2, 2004
  2. Richard Ryerson
    Replies:
    0
    Views:
    2,644
    Richard Ryerson
    Jan 28, 2004
  3. Rick

    DataGrid EditCommandColumn not firing events properly.

    Rick, Jan 28, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    304
    Richard Ryerson
    Feb 2, 2004
  4. Richard Ryerson

    DataGrid EditCommandColumn not firing events properly.

    Richard Ryerson, Jan 28, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    319
    Richard Ryerson
    Jan 28, 2004
  5. Bruce E. Bonsall

    Dynamic EditCommandColumn events

    Bruce E. Bonsall, May 9, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    5
    Views:
    177
Loading...

Share This Page