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

[Solved] DataSource not found with NestedView

3 Answers 344 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 02 Jun 2009, 07:20 PM

Grid with nested view is reporting the following error when I execute the Insert or Edit command.  Without the nested view, Insert and Edit works fine in grdEntities.  The nested view portion works fine right now as is(including the user control assocaited with the grdEndorsements).  What happens is that when I issue the Insert Command from the grdEntities header or an Edit command from one of the rows in the grdEntities mastertable, I get the following error:

The DataSourceID of 'grdEndorsements' must be the ID of a control of type IDataSource.  A control with ID 'SDSGetEndorsements' could not be found.

Here is the code:

<telerik:RadGrid ID="grdEntities" runat="server" Skin="Telerik" 
GridLines="None" AllowPaging="True" AllowSorting="True" Width="99%" AutoGenerateColumns="False" 
ShowStatusBar="True" Visible ="true" ShowFooter="True" AllowMultiRowEdit="true">  
<MasterTableView GridLines="None" Width="100%" CommandItemDisplay="Top"   
   DataKeyNames="EntityID" NoMasterRecordsText="No Entities to Display." > 
<NestedViewTemplate> 
<asp:Label ID="LabelEntityID" Font-Bold="true" Font-Italic="true" Text='<%# Eval("EntityID") %>' 
            Visible="false" runat="server" /> 
     <telerik:RadGrid ID="grdEndorsements" runat="server" Skin="Telerik" 
    GridLines="None" AllowPaging="True" AllowSorting="True" Width="99%" AutoGenerateColumns="False" 
    ShowStatusBar="True" Visible ="true" ShowFooter="True" DataSourceID="SDSGetEndorsements">  
    <MasterTableView GridLines="None" Width="100%" CommandItemDisplay="Top" HierarchyLoadMode="ServerOnDemand"   
       DataKeyNames="EndorsementID" NoMasterRecordsText="No Endorsements to Display." PageSize="5">  
    <CommandItemSettings AddNewRecordText="Add New Endorsement" /> 
    <Columns> 
        <telerik:GridEditCommandColumn> 
        </telerik:GridEditCommandColumn> 
        <telerik:GridBoundColumn UniqueName="EndorsementID" HeaderText="EndorsementID" DataField="EndorsementID" Visible="False" > 
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn UniqueName="EntityID" HeaderText="EntityID" DataField="EntityID" Visible="False" > 
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn UniqueName="EndorsementName" HeaderText="Name" DataField="EndorsementName" Visible="True" > 
        </telerik:GridBoundColumn> 
        <telerik:GridBoundColumn UniqueName="EndorsementTitle" HeaderText="Title" DataField="EndorsementTitle">  
        </telerik:GridBoundColumn>                      
        <telerik:GridBoundColumn UniqueName="EndorsementSSN"  HeaderText="SSN" DataField="EndorsementDate">  
        </telerik:GridBoundColumn>   
        <telerik:GridBoundColumn UniqueName="EndorsementDate" HeaderText="Date Endorsed" DataField="EndorsementDate">  
        </telerik:GridBoundColumn> 
 
    </Columns> 
    <EditFormSettings  UserControlName="~/UserControls/AddEditEndorsement.ascx" EditFormType="WebUserControl">  
        <EditColumn UniqueName="EditCommandColumnE1">  
        </EditColumn> 
    </EditFormSettings> 
    <ExpandCollapseColumn> 
        <HeaderStyle Width="20px" /> 
    </ExpandCollapseColumn> 
    <RowIndicatorColumn> 
        <HeaderStyle Width="20px" /> 
    </RowIndicatorColumn> 
    </MasterTableView> 
    <ClientSettings> 
        <Scrolling AllowScroll="False" /> 
    </ClientSettings> 
    <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" /> 
    <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" /> 
    <AlternatingItemStyle HorizontalAlign="Left" VerticalAlign="Middle" /> 
    </telerik:RadGrid>                  
    <asp:SqlDataSource ID="SDSGetEndorsements" runat="server"   
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"   
        SelectCommand="SELECT * FROM [OldEndorsements] WHERE ([EntityID] = @EntityID)">  
        <SelectParameters> 
            <asp:ControlParameter ControlID="LabelEntityID" PropertyName="Text" Type="String" Name="EntityID" /> 
            </SelectParameters> 
    </asp:SqlDataSource> 
 
</NestedViewTemplate> 
<CommandItemSettings AddNewRecordText="Add New Entity" /> 
<ExpandCollapseColumn> 
    <HeaderStyle Width="20px" /> 
</ExpandCollapseColumn> 
<Columns> 
    <telerik:GridEditCommandColumn> 
    </telerik:GridEditCommandColumn> 
    <telerik:GridBoundColumn UniqueName="EntityID" HeaderText="EntityID" DataField="EntityID" Visible="False" > 
    </telerik:GridBoundColumn> 
    <telerik:GridBoundColumn UniqueName="EntityType" HeaderText="EntityType" DataField="EntityType" Visible="False" > 
    </telerik:GridBoundColumn> 
     <telerik:GridBoundColumn UniqueName="EntityName" HeaderText="Name" DataField="EntityName" Visible="True" > 
    </telerik:GridBoundColumn> 
    <telerik:GridBoundColumn UniqueName="EntityAddress" HeaderText="Address" DataField="EntityAddress">  
    </telerik:GridBoundColumn>                      
    <telerik:GridBoundColumn UniqueName="EntityAddress2" HeaderText="Address2" DataField="EntityAddress2">  
    </telerik:GridBoundColumn> 
    <telerik:GridBoundColumn UniqueName="EntityCity"  HeaderText="City" DataField="EntityCity">  
    </telerik:GridBoundColumn>   
    <telerik:GridBoundColumn UniqueName="EntityState" HeaderText="State" DataField="EntityState">  
    </telerik:GridBoundColumn>                      
    <telerik:GridBoundColumn UniqueName="EntityZip" HeaderText="Zip" DataField="EntityZip">  
    </telerik:GridBoundColumn> 
    <telerik:GridBoundColumn UniqueName="EntityTaxID" HeaderText="Tax ID" DataField="EntityTaxID">  
    </telerik:GridBoundColumn>    
    <telerik:GridBoundColumn UniqueName="EntityTypeDesc" HeaderText="Type" DataField="EntityTypeDesc">  
    </telerik:GridBoundColumn> 
   
</Columns> 
<EditFormSettings  UserControlName="~/UserControls/AddEditEntity.ascx" EditFormType="WebUserControl">  
    <EditColumn UniqueName="EditCommandColumn1">  
    </EditColumn> 
</EditFormSettings> 
</MasterTableView> 
<ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" /> 
<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="True" /> 
</telerik:RadGrid> 

Thanks.


 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Jun 2009, 11:24 AM
Hello Scott,

Try placing the SDSGetEndorsements outside the NestedViewTemplate and it should work as expected.
aspx:
  <asp:SqlDataSource ID="SDSGetEndorsements" runat="server"    
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"    
        SelectCommand="SELECT * FROM [OldEndorsements] WHERE ([EntityID] = @EntityID)">   
        <SelectParameters>  
            <asp:ControlParameter ControlID="LabelEntityID" PropertyName="Text" Type="String" Name="EntityID" />  
            </SelectParameters>  
    </asp:SqlDataSource>  
 
<telerik:RadGrid ID="grdEntities" runat="server" Skin="Telerik"  
GridLines="None" AllowPaging="True" AllowSorting="True" Width="99%" AutoGenerateColumns="False"  
ShowStatusBar="True" Visible ="true" ShowFooter="True" AllowMultiRowEdit="true">   
<MasterTableView GridLines="None" Width="100%" CommandItemDisplay="Top"    
   DataKeyNames="EntityID" NoMasterRecordsText="No Entities to Display." >  
<NestedViewTemplate>  
       ..... 
     <telerik:RadGrid ID="grdEndorsements" runat="server" Skin="Telerik"  
    GridLines="None" AllowPaging="True" AllowSorting="True" Width="99%" AutoGenerateColumns="False"  
    ShowStatusBar="True" Visible ="true" ShowFooter="True" DataSourceID="SDSGetEndorsements">   
     ...... 
    </telerik:RadGrid>   
</NestedViewTemplate>  
 ...... 

Thanks
Princy.
0
Scott
Top achievements
Rank 1
answered on 04 Jun 2009, 01:51 PM
Hi Princy,

When I moved the SDSGetEndorsements out of the Template the Control Parameter (LabelEntityID) could not be found and errored out.  However, interestingly, when I moved the SDSGetEndorsements data source to the very top of the Nested View it works and I now have no issues with issuing an Edit/Insert on grdEntities.

I do have an issue though now and I think it's still relevant to this post so I'll ask it here:

I'll be using the user control called AddEditEndorsement.ascx to handle the Insert/Edit of items in the Nested View grid grdEndorsements.  Can you provide an example of how I would access the Insert and Update events fired from the grdEndorsements grid?  Since it is in the Nested View template, I'm at a loss as to how to go about getting at those events in code behind.  I suppose I could do it all in the user control but I'm wondering if there is a way to access the grdEndorsements_InsertCommand event and the grdEndorsements_UpdateCommand?

Thanks a lot for your help.

Scott
0
Accepted
Princy
Top achievements
Rank 2
answered on 05 Jun 2009, 06:00 AM
Hello Scott,

In the Smart tag for RadGrid in design view, you will find a link that reads EditTemplates. This Edit Templates link lets you launch the template design surface for a particular template that the grid uses. You can then select from the drop-down list of all possible templates the nested view template and access the nested grids property windowto add event handlers directly to the grid. This is available with the latest version of RadGrid for Asp.Net Ajax(2009.01.0311.20). So if you are using an older version you can add the event handlers manually.

Thanks
Princy.
Tags
Grid
Asked by
Scott
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Scott
Top achievements
Rank 1
Share this question
or