Telerik Radgrid datasource with stored procedure

2 posts, 0 answers
  1. Ana
    Ana avatar
    12 posts
    Member since:
    Apr 2014

    Posted 20 Jun 2014 Link to this post

    Hi,

    I have a Hierarchical Grid. The master one has a data source tied with a stored procedure.

    I have created the nested/hierarchical data with another data source tied with a stored procedure.

    Both stored procedures have a common fields which I did a relation.   The master view data is displaying correctly.  No issues here. But, when I clicked on expand of master grid, I don't get the child items. No child records to display is the message I see.  But, it has data in database and see when I individually run the stored procedures.

    I followed this video but wasn't successful.  http://tv.telerik.com/watch/radcontrols-for-aspnet-ajax/radgrid-using-the-designer-to-create-a-hierarchical-grid

    I am not sure what I did wrong.  Can anyone please give me an example to bind data sources using stored procedures?


    Thank you.
  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 25 Jun 2014 Link to this post

    Hello Ana,

    I am sending you a simple example based on our hierarchy demo:
    http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/declarative-relations/defaultcs.aspx
    The example uses two stored procedures:

    USE [NORTHWIND.MDF]
    GO
    /****** Object:  StoredProcedure [dbo].[GetCustomers]    Script Date: 6/25/2014 1:56:12 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[GetCustomers]
    AS
       SELECT * FROM Customers
    And
    USE [NORTHWIND.MDF]
    GO
    /****** Object:  StoredProcedure [dbo].[GetOrders]    Script Date: 6/25/2014 1:59:38 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[GetOrders]
        @CustomerID nvarchar(50)
    AS
        SET NOCOUNT ON;
        SELECT * FROM Orders Where CustomerID = @CustomerID

    The SqlDataSources are configured to use these stored procedures:
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="GetCustomers" SelectCommandType="StoredProcedure"
            runat="server"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            ProviderName="System.Data.SqlClient" SelectCommand="GetOrders" SelectCommandType="StoredProcedure"
            runat="server">
            <SelectParameters>
                <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" Type="string"></asp:SessionParameter>
            </SelectParameters>
        </asp:SqlDataSource>
       
    Please check the example and let me know what differs in your case.

    Regards,
    Radoslav
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top