Using SqlDataSource - but how do I provide it with parameters at runtime?

Posted on 2007-10-11
Last Modified: 2012-05-05
From the Toolbox I have selected a SqlDataSource.  It has a wizard for building the Select statement, but how do I provide parameters to this Select statement at runtime?  What does my Select statement look like and what do I need to do in the code behind?

I need detailed steps.


Question by:knowlton
    LVL 27

    Expert Comment

    You can still use the same wizard to provide parameters
    after the first step "Connection step" the second step the wizard will show 3 buttons Where, Order By and Advanced
    if you click on the where button you will get the option to select params
    Column, Operator and source
    once you select the first param you have to click on Add to add it
    LVL 5

    Author Comment

    And then in the code behind, what do I do?
    LVL 5

    Author Comment

    The problem is I am building my own SQL Statement in the DataSource.

    When I select that option....the Advanced button becomes disabled.
    LVL 27

    Accepted Solution

    You dont do nothing in code behind
    an example of a control parameters
     <asp:ControlParameter ControlID="MyCOntrolID" Name="DataFieldName" PropertyName="Text" Type="String" />
    best if you create a testpage and use the wizard to to create the parameters for you then copy them to your existing page

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    755 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

    17 Experts available now in Live!

    Get 1:1 Help Now