Form Query and GridView for ASP.NET 2.0

D

dm1608

Hi all --

I'm rapidly learning ASP.NET 2.0 (never really did much .NET before...
mainly an ASP and PHP guy until now) and seem to be having some technical
challenges that I'm hoping someone can help me with.

I've created an n-tier application that consists of a Business Access Lay
and a Data Access Layer to query a SQL Server database. The classes are
stored within my App_Code directory.

The application is a rewrite of one of my earlier ASP applications where I
have a form that a user selects various checkboxes and dropdown lists and/or
types in a text string that will query a database and return all rows that
match that criteria.

One of the changes that I'm making is adding Peter Blum's DataTextBox
controls for a "Start" and "End" date prompt to be used to filter records by
date.

The issue that I'm having is that for some reason, when a user enters a date
such as "02/18/2005" and Peter's DateTextBox.Text property shows
"02/18/2005" and this is the property that I bound my ObjectDataSource to
for the GridView that I'm using. When the date gets passed to my BAL, it is
showing as "02/18/2005 12:00:00 AM". I've tried changing the data type of
the "StartDate" variable to be of type string instead of DateTime and I'm
still getting the same results.

This is causing me issues because if the user wants to query all rows for
today, the StartDate will be 02/18/2005 12:00:00 AM and the EndDate will
also be 02/18/2005 12:00:00 AM which causes no rows to be returned.

I want to somehow get rid of the time and add it to my DAL's SQL
statement... to use 12:00:00 AM for the start time and 23:59:59 for the end
time.

Has anyone else experienced these sort of issues before.

I have even tried changing all my references to StartDate and EndDate to be
of type string... Howver, when I try and do an Add() method to my generic
collection, an exception is thrown about not being able to convert a
DateTime type to a string type; even though I typed-casted the field to a
string.

Any help would this would be appreciated.
 
O

Otis Mukinfus

Hi all --

I'm rapidly learning ASP.NET 2.0 (never really did much .NET before...
mainly an ASP and PHP guy until now) and seem to be having some technical
challenges that I'm hoping someone can help me with.

I've created an n-tier application that consists of a Business Access Lay
and a Data Access Layer to query a SQL Server database. The classes are
stored within my App_Code directory.

The application is a rewrite of one of my earlier ASP applications where I
have a form that a user selects various checkboxes and dropdown lists and/or
types in a text string that will query a database and return all rows that
match that criteria.

One of the changes that I'm making is adding Peter Blum's DataTextBox
controls for a "Start" and "End" date prompt to be used to filter records by
date.

The issue that I'm having is that for some reason, when a user enters a date
such as "02/18/2005" and Peter's DateTextBox.Text property shows
"02/18/2005" and this is the property that I bound my ObjectDataSource to
for the GridView that I'm using. When the date gets passed to my BAL, it is
showing as "02/18/2005 12:00:00 AM". I've tried changing the data type of
the "StartDate" variable to be of type string instead of DateTime and I'm
still getting the same results.

This is causing me issues because if the user wants to query all rows for
today, the StartDate will be 02/18/2005 12:00:00 AM and the EndDate will
also be 02/18/2005 12:00:00 AM which causes no rows to be returned.

I want to somehow get rid of the time and add it to my DAL's SQL
statement... to use 12:00:00 AM for the start time and 23:59:59 for the end
time.

Has anyone else experienced these sort of issues before.

I have even tried changing all my references to StartDate and EndDate to be
of type string... Howver, when I try and do an Add() method to my generic
collection, an exception is thrown about not being able to convert a
DateTime type to a string type; even though I typed-casted the field to a
string.

Any help would this would be appreciated.
When you get the DateTime values from the control, try this:

Assuming the date are DateTime objects:

if the End date is MM/dd/yyy 00:00:00 AM, leave it alone. Then do this: EndDate.AddHours(24);

Now you have a date time range that includes all 24 hours of the end points.

Is that what you want?


Otis Mukinfus
http://www.otismukinfus.com
http://www.tomchilders.com
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top