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

Detailtables Lose Datasource on Edit / Insert

6 Answers 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mitchell
Top achievements
Rank 1
Mitchell asked on 13 Jul 2010, 01:52 PM
Hey guys, I have a page with a radgrid setup with one detail table under my mastertableview and two detail tables under the first detail table. If there is no data in either of the second level of detail tables there will be a gridbutton column visible to add new data. If we add or edit that data, the adjacent detailtable row loses its datasource and we no longer see the column. How can i prevent this?

Here is how my grid is setup:

<telerik:RadGrid runat="server" ID="rgReportGrid" AutoGenerateColumns="False" 
            BorderColor="Navy" BorderWidth="2px" GridLines="None" AllowSorting="true" Width="100%">
            <MasterTableView DataKeyNames="BASE_ISSUE_ID" AutoGenerateColumns="false" CommandItemDisplay="Top">
                <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add New Base Issue" />
                  
                <DetailTables>
                    <telerik:GridTableView Name="ChildDescription" DataKeyNames="ISSUE_ID, ISSUE_NUMBER" Width="100%">
                          
                        <DetailTables>
                            <telerik:GridTableView Name="CDNData" DataKeyNames="ID, BASE_ISSUE_NUM, LIST_ID" Width="100%">
                                  
                                <Columns>                                    
                                    <telerik:GridButtonColumn ButtonType="LinkButton" HeaderText="Add New Issue" Text="Add Issue" UniqueName="AddCDNIssue" Visible="false" 
                                        CommandName="AddNewIssue" CommandArgument="CDN">
                                    </telerik:GridButtonColumn>
                                    <telerik:GridEditCommandColumn HeaderText="Edit" UniqueName="EditCommandColumn" Visible="true">
                                    </telerik:GridEditCommandColumn>
                                    <telerik:GridButtonColumn ButtonType="LinkButton" HeaderText="Delete" UniqueName="DeleteCommandColumn" CommandName="DeleteSelectedSub" Text="Delete"
                                        ConfirmDialogType="Classic" ConfirmText="Delete Selected Known Issue?">
                                    </telerik:GridButtonColumn>
                                    <telerik:GridBoundColumn HeaderText="Affects CDN" DataField="CDN">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Identified In Version" DataField="IDENTIFIED_IN_VERSION">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Date Published" DataField="PUBLISHED_DT">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Category" DataField="CATEGORY">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="PR #" DataField="PR">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="EMS #" DataField="EMS">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Fixed Status" DataField="FIXED_STATUS">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Fixed Date" DataField="FIXED_DATE">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Ending Build" DataField="ENDING_BUILD">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Issue ID" DataField="ID"  Visible="false">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridboundColumn HeaderText="Base Issue ID" DataField="BASE_ISSUE_NUM" Visible="false">
                                    </telerik:GridboundColumn>
                                    <telerik:GridBoundColumn HeaderText="List ID" DataField="LIST_ID" Visible="false">
                                    </telerik:GridBoundColumn>
                                </Columns>
                                  
                                <EditFormSettings UserControlName="Known_Issue.ascx" EditFormType="WebUserControl">
                                </EditFormSettings>
                            </telerik:GridTableView>
                            <telerik:GridTableView Name="USAData" DataKeyNames="ID, BASE_ISSUE_NUM, LIST_ID" Width="100%">
                                  
                                <Columns>
                                    <telerik:GridButtonColumn ButtonType="LinkButton" HeaderText="Add New Issue" Text="Add Issue" UniqueName="AddUSAIssue" Visible="false"
                                        CommandName="AddNewIssue" CommandArgument="USA">
                                    </telerik:GridButtonColumn>
                                    <telerik:GridEditCommandColumn HeaderText="Edit" UniqueName="EditCommandColumn" Visible="true">
                                    </telerik:GridEditCommandColumn>
                                    <telerik:GridButtonColumn ButtonType="LinkButton" HeaderText="Delete" UniqueName="DeleteCommandColumn" CommandName="DeleteSelectedSub" Text="Delete"
                                        ConfirmDialogType="Classic" ConfirmText="Delete Selected Known Issue?">
                                    </telerik:GridButtonColumn>
                                    <telerik:GridBoundColumn HeaderText="Affects USA" DataField="USA">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Identified In Version" DataField="IDENTIFIED_IN_VERSION">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Date Published" DataField="PUBLISHED_DT">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Category" DataField="CATEGORY">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="PR #" DataField="PR">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="EMS #" DataField="EMS">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Fixed Status" DataField="FIXED_STATUS">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Fixed Date" DataField="FIXED_DATE">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Ending Build" DataField="ENDING_BUILD">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn HeaderText="Issue ID" DataField="ID" Visible="false">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridboundColumn HeaderText="Base Issue ID" DataField="BASE_ISSUE_NUM" Visible="false">
                                    </telerik:GridboundColumn>
                                    <telerik:GridBoundColumn HeaderText="List ID" DataField="LIST_ID" Visible="false">
                                    </telerik:GridBoundColumn>
                                </Columns>
                                  
                                <EditFormSettings UserControlName="Known_Issue.ascx" EditFormType="WebUserControl" >
                                </EditFormSettings>
                            </telerik:GridTableView>
                        </DetailTables>
                          
                        <Columns>
                            <telerik:GridBoundColumn HeaderText="Description" DataField="DESCRIPTION">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Work Around" DataField="WORK_AROUND">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Work Around Description" DataField="WORK_AROUND_DESCRIPTION">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn HeaderText="Issue ID" DataField="ISSUE_ID" Visible="False">
                            </telerik:GridBoundColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>            
              
                <Columns>
                    <telerik:GridEditCommandColumn HeaderText="Edit" UniqueName="EditCommandColumn">
                    </telerik:GridEditCommandColumn>
                    <telerik:GridButtonColumn ButtonType="LinkButton" HeaderText="Delete" UniqueName="DeleteCommandColumn" CommandName="DeleteSelected" Text="Delete"
                        ConfirmDialogType="Classic" ConfirmText="Delete Selected Known Issue Base?">
                    </telerik:GridButtonColumn>
                    <telerik:GridBoundColumn HeaderText="Issue Number" DataField="BASE_ISSUE_NUM">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Title" DataField="TITLE">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Internal Status" DataField="INTERNAL_STATUS">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Internal Status Comments" DataField="INTERNAL_STATUS_COMMENT">
                    </telerik:GridBoundColumn>                   
                    <telerik:GridBoundColumn HeaderText="Severity" DataField="SEVERITY">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Affects CDN" DataField="CDN">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Affects USA" DataField="USA">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Issue ID" DataField="BASE_ISSUE_ID" Visible="false">
                    </telerik:GridBoundColumn>
                </Columns>
                  
                <EditFormSettings UserControlName="Known_Issue_Base.ascx" EditFormType="WebUserControl">
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>

6 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 15 Jul 2010, 02:08 PM
Hi Mitchell,

Losing data on update/insert or other grid operation often indicates misconfigured databinding for your RadGrid's master and detail tables. To properly setup databinding, refer to the 2 supported databinding mechanisms with hierarchical grid structure:

1. Hierarchical databinding using declarative data source controls

2. Hierarchical databinding using the DetailTableDataBind event

Only these two databinding scenarios are supported with hierarchical tables in RadGrid, so make sure you follow one of the two.

Regards,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Carlos Rodriguez
Top achievements
Rank 1
answered on 15 Apr 2011, 03:38 PM
I have the same problem and use the event DetailTableDataBind, when I click Edit (GridEditCommandColumn type column) disappear data detail table. Debug the code and then clicking on Edit, only run the Page_Load methods.

Here is my Post:
http://www.telerik.com/community/forums/aspnet-ajax/grid/problems-with-relationship-between-master-table-and-detail-table.aspx
0
Veli
Telerik team
answered on 18 Apr 2011, 11:52 AM
Hello Carlos,

If your detail table data shows OK the first you expand a parent item, it means the DetailTableDataBind event is firing OK and your detail table gets properly databound. The fact  that you do not get any data when clicking on Edit indicates the DetailTableDataBind event is not properly databinding your detail table. To troubleshoot, verify the following 2 conditions:

1. The event handler is properly attached on postback. The sample code you provided does not indicate where and how you attach your event handlers. You need to make sure they are attached on every postback.

2. The DetailTableDataBind event is executing OK without any exceptions. As you are using a try-catch block in your event handler, an exception thrown during its execution may prevent proper detail table databinding. You can temporarily remove the try-catch block and verify the code runs OK.

Veli
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Carlos Rodriguez
Top achievements
Rank 1
answered on 18 Apr 2011, 10:28 PM
Veli Hello such!
Event handlers are declared in the Page_Load method and are as follows:

// EVENTOS DEL GRID DE ORDENES DE COMPRA
radGriOrdCompras.DetailTableDataBind += new Telerik.Web.UI.GridDetailTableDataBindEventHandler(radGriOrdCompras_DetailTableDataBind);
radGriOrdCompras.MasterTableView.DetailTables.OwnerGrid.ItemDataBound += new Telerik.Web.UI.GridItemEventHandler(OwnerGrid_ItemDataBound);
radGriOrdCompras.DeleteCommand += new Telerik.Web.UI.GridCommandEventHandler(radGriOrdCompras_DeleteCommand);
// EVENTOS DEL GRID DE PRODUCTOS SELECCIONADOS
radGriOrdComDetalles.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(radGriOrdComDetalles_NeedDataSource);
radGriOrdComDetalles.DetailTableDataBind += new Telerik.Web.UI.GridDetailTableDataBindEventHandler(radGriOrdComDetalles_DetailTableDataBind);
radGriOrdComDetalles.ItemDataBound += new Telerik.Web.UI.GridItemEventHandler(radGriOrdComDetalles_ItemDataBound);
radGriOrdComDetalles.ItemCreated += new Telerik.Web.UI.GridItemEventHandler(radGriOrdComDetalles_ItemCreated);
radGriOrdComDetalles.ItemCommand += new Telerik.Web.UI.GridCommandEventHandler(radGriOrdComDetalles_ItemCommand);

When removing try-catch block does not generate any exception. When I click the edit button, to make the Postback only runs the Page_Load method and no method is executed DetailTableDataBind.

0
Carlos Rodriguez
Top achievements
Rank 1
answered on 19 Apr 2011, 02:44 PM
I will create a project that reproduces the problem I have in my project and post it here, if possible, is there any where to send mail?. The email title is "shiru_jan"so they can identify.

Tks!!!!
0
Veli
Telerik team
answered on 21 Apr 2011, 07:16 AM
Hi Carlos,

If you need to send a sample project, consider opening a regular support ticket by logging in through your Client.NET account in www.telerik.com. Please refer to this forum thread in the ticket.

Veli
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Mitchell
Top achievements
Rank 1
Answers by
Veli
Telerik team
Carlos Rodriguez
Top achievements
Rank 1
Share this question
or