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

Manual updates and inserts in a details table

1 Answer 42 Views
Grid
This is a migrated thread and some comments may be shown as answers.
andieje
Top achievements
Rank 1
andieje asked on 29 Jul 2009, 05:51 PM
Hello

Are there any examples that show how to manually insert/update rows in a details table. I have found an example for how to do this manually to a master table but that involves saving the data source in view state. I can't imagine you could save all of the details tables for a grid in view state

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 30 Jul 2009, 04:34 AM
Hi,

You may refer the following code library submission which explains how to perform manual insert/update/delete operations in RadGrid. You can use the same logic to perform the CRUD operation with Detail table as well. You may set the Name property for the Master and Detail table. In the InsertCommand/UpdateCommand event you may differentiate the Master/Detail table using its Name and hence perform the CRUD operations.
Manual Insert/Update/Delete operations using Auto-generated editform with sql statements from the code-behind

ASPX:
 
<MasterTableView  DataSourceID="SqlDataSource1" AllowFilteringByColumn="true" Name="Master"   CommandItemDisplay="top" > 
                     
                       ............ 
                    <DetailTables> 
                      <telerik:GridTableView runat="server" DataSourceID="SqlDataSource2" CommandItemDisplay="top"  Name="Detail" > 
                          ......... 
 
                      </telerik:GridTableView> 
                    </DetailTables> 
                </MasterTableView> 
 

CS:
 
 protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.Item.OwnerTableView.Name == "Master"
        {  
          //perform Insert Operation for master table 
        } 
 
        else if (e.Item.OwnerTableView.Name == "Detail"
        {  
          //perform Insert Operation for child table 
        } 
    } 


Regards
Princy
Tags
Grid
Asked by
andieje
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or