e.CommandName Always = "Edit"

Discussion in 'ASP .Net Datagrid Control' started by Scot, Jul 6, 2005.

  1. Scot

    Scot Guest

    I have dropped a DataGrid (.NET Framework 1.1) on a page, and using the VS
    DataGrid Property Wizard, have added a button column with Edit, Update,
    Cancel.

    The grid displays correctly and when I click the Edit button, I get the
    expected result of the Edit Command being triggered. My problem is that
    once I change a value and click the Update button, the EditCommand is being
    triggered, not the UpdateCommand.

    Does anyone have any ideas about what I might have done wrong / forgotten to
    set up.

    Thanks in advance, code to follow.
    Scot

    private void InitializeComponent()

    {

    this.DataGridItemGrid.CancelCommand += new
    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGridItemGrid_
    CancelCommand);

    this.DataGridItemGrid.EditCommand += new
    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGridItemGrid_
    EditCommand);

    this.DataGridItemGrid.UpdateCommand += new
    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGridItemGrid_
    UpdateCommand);

    this.Load += new System.EventHandler(this.Page_Load);

    }



    private void DataGridItemGrid_EditCommand(object source,
    System.Web.UI.WebControls.DataGridCommandEventArgs e)

    {

    DataGridItemGrid.EditItemIndex = e.Item.ItemIndex;

    BindData();

    }



    private void DataGridItemGrid_UpdateCommand(object source,
    System.Web.UI.WebControls.DataGridCommandEventArgs e)

    {

    PriceUpdater.StoreUpdater su = new PetShop.Web.PriceUpdater.StoreUpdater();

    bool updateValid = su.UpdatePrices(ds);

    }
     
    Scot, Jul 6, 2005
    #1
    1. Advertising

  2. Scot

    Elton Wang Guest

    One reason to cause the problem might be disabled datagrid's viewstate.

    HTH

    Elton Wang

    "Scot" <> wrote in message
    news:...
    > I have dropped a DataGrid (.NET Framework 1.1) on a page, and using the VS
    > DataGrid Property Wizard, have added a button column with Edit, Update,
    > Cancel.
    >
    > The grid displays correctly and when I click the Edit button, I get the
    > expected result of the Edit Command being triggered. My problem is that
    > once I change a value and click the Update button, the EditCommand is

    being
    > triggered, not the UpdateCommand.
    >
    > Does anyone have any ideas about what I might have done wrong / forgotten

    to
    > set up.
    >
    > Thanks in advance, code to follow.
    > Scot
    >
    > private void InitializeComponent()
    >
    > {
    >
    > this.DataGridItemGrid.CancelCommand += new
    >

    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGridItemGrid_
    > CancelCommand);
    >
    > this.DataGridItemGrid.EditCommand += new
    >

    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGridItemGrid_
    > EditCommand);
    >
    > this.DataGridItemGrid.UpdateCommand += new
    >

    System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGridItemGrid_
    > UpdateCommand);
    >
    > this.Load += new System.EventHandler(this.Page_Load);
    >
    > }
    >
    >
    >
    > private void DataGridItemGrid_EditCommand(object source,
    > System.Web.UI.WebControls.DataGridCommandEventArgs e)
    >
    > {
    >
    > DataGridItemGrid.EditItemIndex = e.Item.ItemIndex;
    >
    > BindData();
    >
    > }
    >
    >
    >
    > private void DataGridItemGrid_UpdateCommand(object source,
    > System.Web.UI.WebControls.DataGridCommandEventArgs e)
    >
    > {
    >
    > PriceUpdater.StoreUpdater su = new

    PetShop.Web.PriceUpdater.StoreUpdater();
    >
    > bool updateValid = su.UpdatePrices(ds);
    >
    > }
    >
    >
     
    Elton Wang, Jul 7, 2005
    #2
    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. John Blair

    asp:linkbutton - commandname behaviour

    John Blair, Dec 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,997
    John Blair
    Dec 30, 2004
  2. Irfi
    Replies:
    0
    Views:
    637
  3. Irfi
    Replies:
    0
    Views:
    444
  4. =?Utf-8?B?RGFiYmxlcg==?=

    use Formview cancel commandname to return to GridView Page?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 20, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    5,233
    =?Utf-8?B?RGFiYmxlcg==?=
    Mar 20, 2006
  5. ChemFinder
    Replies:
    0
    Views:
    918
    ChemFinder
    Apr 1, 2006
Loading...

Share This Page