SqlDataSource with parameter

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • E. Kwong

    #1

    SqlDataSource with parameter

    I just want to select records with a certain date field today's date:

    <asp:SqlDataSou rce ID="src1" runat="server" ConnectionStrin g="<%$
    ConnectionStrin gs:xyz %>"

    SelectCommand=" SELECT * FROM [Events] WHERE [Startdate] ? "
    OnSelected="src 1_Selected">

    <SelectParamete rs>

    <asp:Paramete r Name="Startdate " Type="DateTime" />

    </SelectParameter s>

    </asp:SqlDataSour ce>

    ---------------------

    protected void srcEvents_Selec ted(object sender,
    SqlDataSourceSt atusEventArgs e)

    {

    e.Command.Param eters["Startdate"].Value = DateTime.Today;

    }

    -------------------

    I have a list control bind to this data source but when executed the list
    doesn't show. That means no record is selected. I know there are
    qualifying records since I input them myself in SQL server.

    Am newbie so I must code something wrong. Any insignt appreciated.





Working...