Display query results based on selected fields

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.
 
N

Noldis Chumacero Chávez

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.
 
M

Mike

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?
 
N

Noldis Chumacero Chávez

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top