Getting results to display via a stored procedure

2 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. DevCraft R3 2016 release webinar banner
Back to Top