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

stored procedure call from grid

1 Answer 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
COURTNEY LYNCH
Top achievements
Rank 1
COURTNEY LYNCH asked on 16 Jun 2009, 09:16 PM
I'm using a linkbutton delete column on a master/detail grid.  On linkbutton click, I want to call a stored procedure via SQL datasource that looks for and identifier in the details table.  If it exists, it returns a code and an error will display.  If not, it deletes the record from the master grid.  I'm having trouble finding an example of how to do this.  Could you please point me in the right direction? 

1 Answer, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 18 Jun 2009, 11:59 AM
Hello COURTNEY,

The described scenario can easily be implemented in RadGrid's ItemCommand event, where your e.Item event property references the data item in the detail table for which the command has been fired, and after casting it to GridDataItem, its OwnerTableView.ParentItem references the corresponding data item from the parent item of the detail table:

void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
    if (e.CommandName == "MyCustomCommandName"
    { 
        GridDataItem item = e.Item as GridDataItem; 
        string myValue = item["ColumnUniqueName"].Text; 
        if (myValue == "some string"
        { 
            GridDataItem parentItem = item.OwnerTableView.ParentItem; 
            //I can now access my detil table's parent item and its fields 
        } 
    } 

The above example, used together with SQL calls, an approach similar to the one described in this help article, can be used to execute a database query, return some value and delete an item right inside RadGrid's ItemCommand event.

Kind regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
COURTNEY LYNCH
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or