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

RadGrid DetailTable Programmatic Insert Command

2 Answers 187 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 04 Apr 2013, 11:18 PM
I'm attempting to do a programmatic insert to a DetailTable in a RadGrid, however I can not find an equivalent "OnInsertCommand" for the DetailTables as I use for the MasterTable.

Is there an equivalent, or is the solution to run the database insert during the onItemCommand event and just verify which detail table is running the insert/edit command? I am using the GridEditCommandColumn within the DetailTable and was hoping there were built in Insert/Edit handlers. I'm using OnDetailTableDataBind to bind the detail table, but didn't see any for Insert/Edit.


2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 05 Apr 2013, 04:28 AM
Hi,

You can check for the CommandName as shown below.
C#:
protected void grid_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.PerformInsertCommandName && e.Item.OwnerTableView.Name == "DetailTable1")
        {
           
        }
}

Thanks,
Shinu
0
James
Top achievements
Rank 1
answered on 10 Apr 2013, 08:02 PM
Thanks that is how it can be done through the OnItemCommand function, although I did discover something else that I missed initially.

The OnInsertCommand and OnUpdateCommand functions that are defined at the RadGrid level with fire for both the Master and Detail tables when using the built in GridEditTemplateColumn and CommandItem for edit/insert. 

In order to do a different programmatic insert/update for the master table view and detail tables I just check the ownertableview name in function.

protected void Grid_OnEditCommand(object sender, GridCommandEventArgs e) {
     
GridEditableItem item = e.Item as GridEditableItem;
 
    if (item.OwnerTableView.Name == "Grid Table View Name") {
    //detail table update by GridTableViewName
    }
 
 
    if (item.OwnerTableView.Name == "") {
     //Master Table Update
    }
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
James
Top achievements
Rank 1
Share this question
or