This is a migrated thread and some comments may be shown as answers.

ItemUpdated and ItemInserted doesn't fire

1 Answer 187 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Weeble
Top achievements
Rank 1
Weeble asked on 08 Sep 2011, 01:58 PM
Hi,

My RadGrid is all created programmatically in the page_init.  The data source is a DataTable.

The OnNeedDataSource seems fine (well, there is data!), but when I put in into edit mode to add a new row - add data and click on the tick - it does nothing.  The events aren't called.

The event handers are added in the method called by the page_init :

private void CreateForecastGrid()
{
.
.
.
.
.
             //Add the Notes column
                GridTemplateColumn notes = new GridTemplateColumn();
                RadGrid1.MasterTableView.Columns.Add(notes);
  
                notes.ItemTemplate = new NotesDataGridTemplate(ListItemType.Item, "lblNotes");
                notes.EditItemTemplate = new NotesDataGridTemplate(ListItemType.EditItem, "tbNotes");
                notes.HeaderText = "Notes";
                notes.UniqueName = "Notes";
                notes.SortExpression = "Notes";
  
                //Add the Discipline column
.
.
.
            //Add event handlers
            RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_OnNeedDataSource);
            RadGrid1.ItemUpdated += new GridUpdatedEventHandler(RadGrid1_ItemUpdated);
            RadGrid1.ItemInserted += new GridInsertedEventHandler(RadGrid1_ItemInserted);
            RadGrid1.ItemDataBound += new GridItemEventHandler(RadGrid1_OnItemDataBound);
            RadGrid1.DataBound += new EventHandler(RadGrid1_DataBound);
  
            //Add the grid to the view
            RadGridPlaceholder.Controls.Add(RadGrid1);
        }

What am I doing wrong?

Thanks

1 Answer, 1 is accepted

Sort by
0
Weeble
Top achievements
Rank 1
answered on 13 Sep 2011, 09:49 AM
Sorted!

Rather than use ItemUpdated, I needed to use the Command items - and remove the AutoUpdate = true parts:
RadGrid1.InsertCommand += new GridCommandEventHandler(RadGrid_OnInsertCommand);
RadGrid1.UpdateCommand +=new GridCommandEventHandler(RadGrid_OnUpdateCommand);

Now, my events fire perfectly.


Tags
Grid
Asked by
Weeble
Top achievements
Rank 1
Answers by
Weeble
Top achievements
Rank 1
Share this question
or