Solved Populating the GridView from data from a Stored Procedure

Posted on 2007-07-23
Last Modified: 2013-11-07
I am programming in ASP.Net and my form is just a search in the database that returns data to a gridview. I am using a stored procedure that that assembles the sql statemnet based on the parameters and excutes that SQL. The last line of the Stored Procedure is EXEC(@SQL). @SQL is just a varaible that contains the full select statement based on user options. The problem that I am having is that I donot know how to populate the gridview with the data from the stored procedure.
Question by:TIC06
    LVL 16

    Expert Comment

    Have you tried using a SQL Data Source that calls your stored procedure and then binding to that datasource?
    LVL 12

    Accepted Solution


    <asp:gridview runat="server" id="mySPGV" DataSourceId="spDataSource" />

    <asp:SqlDataSource ID="spDataSource" runat="server" ConnectionString="yourConnection"
          ProviderName="yourProvider" SelectCommandType="StoredProcedure">
          <asp:ControlParameter ControlID="myTextBoxValueForSQL" Name="SQL" PropertyName="Text" />

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now