Editable grid inside formtemplate

3 posts, 0 answers
  1. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 06 Aug 2009 Link to this post

    How can i databind an editable grid (RadGrid2) that is placed inside a formtemplate of another grid (RadGrid1)? And how can I render the RadGrid2 to open all the rows editable at the same time? Using OnNeedDataSource in RadGrid2 doesn't seem to work.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2009 Link to this post

    Hi Roy,

    Here is the sample code to access the Grid inside the EditFormTemplate of another Grid. Try accessing the EditForm Grid in the ItemDataBound event of the Main Grid as shown below.

    ASPX:
     
    <EditFormSettings EditFormType="template"
                            <FormTemplate> 
                                <telerik:RadGrid ID="RadGrid3" AllowPaging="true" PageSize="5"  AllowMultiRowEdit="true" runat="server"
                                 <MasterTableView EditMode="InPlace" ></MasterTableView
                                </telerik:RadGrid> 
                            </FormTemplate> 
                            <EditColumn UniqueName="EditCommandColumn1"  > 
                            </EditColumn> 
                        </EditFormSettings> 

    CS:
     
     protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            
            if ((e.Item is GridEditFormItem) && (e.Item.IsInEditMode)) 
            { 
                GridEditFormItem editform = (GridEditFormItem)e.Item; 
                RadGrid EditGrid = (RadGrid)editform.FindControl("RadGrid3"); 
     
                //bind the Grid 
                EditGrid.DataSourceID = "SqlDataSource1"
                EditGrid.MasterTableView.Rebind(); 
     
                //to set the Grid in edit mode 
                foreach (GridDataItem item in EditGrid.Items) 
                { 
                    item.Edit = true
                } 
                EditGrid.MasterTableView.Rebind(); 
            } 
        } 


    Thanks
    Shinu

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Roy Halvorsen
    Roy Halvorsen avatar
    83 posts
    Member since:
    Oct 2008

    Posted 06 Aug 2009 Link to this post

    Thanks for your answer.
    It works fine, except for if i click on Cancel or Save, the grid inside the formtemplate loses it's datasource and disappears. And I think I will get into more trouble when trying to save or delete data in the rows of the grid. All data is loaded from codebehind, so no markup datasources is in use.
Back to Top