Display query results based on selected fields

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Not sure of the best way to do this since I am just kind of feeling my way
around ASP .NET / c#.
I have a table on an SQL server that I want to query by date and display the
results on the page. I will have 2 date fields on the page that the user can
specify a date range.

How do I get query results to display. I looked briefly at the GridView
control, but that seem to only display static querys.
 
Mike,

1. You need to have two fields to store the first and the second dates.
2. Your query will be build in base of this two fields, you can use a
standar query or a store procedure. You can use a SqlDataSource and build
inside the query (using two dates) and this is the source of your DataView.
3. After you change the fields, you need to update again the GridView using
that information.

BRGDS.
 
Thanks for the quick response. The part that i am having trouble with: In
the SqlDataSource, how do I use the 2 fields to build the query. I am only
seeing a way to build a query with static values?
 
Mike,

Using SqlDataSource control you have tools to build your query. Use this
tools and use the dates for your parameters.

When you are configuring this control you need to use the wizard in order to
get this control working. The wizard will show you

1. Choose your data Connection. Here you can setup you data base.
2. Configure the SQL Statment. Here you can use choose from a Store
Procedure or use a table (a query)
3. Define Custom Statements or Store Procedures. Use here the parameters you
want to change.
4. Define Parameters. In this part you can setup the parameters, every
parameter name you put in the previous step (3).
5. Finally Test the Query.

Use this tools and you will make you page work.

BRGDS
 
Back
Top