Getting results to display via a stored procedure

3 posts, 0 answers
  1. Bill
    Bill avatar
    175 posts
    Member since:
    Apr 2010

    Posted 21 Jan 2013 Link to this post

    I need to display results in a RadGrid from the selected parameters inside a report viewer via a stored procedure.

    Can someone please brifely explain how I can accomplish this based on the below stored procedure: The 4 parameters in the report viewer are selected and used in the stored procedure below:
    ALTER PROCEDURE [dbo].[SelectProductInfoByShipAndDate]
        @CruiseLine nvarchar(max),
        @Ship nvarchar(max),
        @FromDate date,
        @ToDate date
        Select *
            FROM dbo.Daily_Totals
            WHERE CruiseLine IN (SELECT * FROM dbo.SplitParameterValues(@CruiseLine, ','))
              AND Ship IN (SELECT * FROM dbo.SplitParameterValues(@Ship, ','))
              AND [Date] BETWEEN @FromDate AND @ToDate
             ORDER BY CruiseLine, Ship, [Date], Product1Cash, Product2Cash, Product3Cash, Product4Cash, Product5Cash, Product6Cash, Sales
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 21 Jan 2013 Link to this post


    You can bind the RadGrid with the Stored Procedure result in the NeedDataSource event of the RadGrid. Please check the following code snippet I tried.

    public static string connection = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString3"].ConnectionString;
    SqlConnection conn = new SqlConnection(connection);
    public SqlCommand cmd = new SqlCommand();
    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        cmd.Connection = conn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@Parameter2", 4);
        cmd.CommandText = "StoredProcedureName";
        DataSet dt = new DataSet();
        SqlDataAdapter adp = new SqlDataAdapter();
        adp.SelectCommand = cmd;
        RadGrid1.DataSource = dt;

  3. Kathryn
    Kathryn avatar
    1 posts
    Member since:
    Sep 2018

    Posted 02 Oct 2018 in reply to Shinu Link to this post

    Still doesn't work
Back to Top