Gridview will not populate unless I type letters in a textbox

W

WISEMANOFNARNIA

I have a grid view that is dependent on a textbox. If the user types
the letter 'T' in the textbox, it will find all firstnames that begin
with that letter.
If the user types nothing in that textbox, He should find all names,
no matter what they start with.
The gridview is also dependent on some checkboxes. The asp.net
parameter calls these boolean, and in my storedprocedure (that fills
the grid) I call them 'bit'.
I'm finding that the gridview will populate only if I enter at least
one letter in the textbox. If I leave it blank, the gridview does not
populate. In fact, it looks like the stored procedure does not even
get to the first line when this happens.
The relevant parts of the stored procedure look like this:
ALTER PROCEDURE [dbo].[FillFormHistoryGrid]
@FirstName varchar(20) ='',
@LastName varchar(25) = '',
@IncludeApprovals bit = 0,
@IncludeDenials bit = 0,
@IncludeNoDecision bit = 0,
@StartDate datetime, @EndDate datetime, @Agency varchar(50)
AS
BEGIN
FROM MyTable
Where (len(@FirstName) = 0 or fname like @FirstName + '%') and
(len(@LastName) = 0 or lname like @LastName + '%') and

Has anyone run into this before?
Thanks,
Marv
 
L

Lloyd Sheen

WISEMANOFNARNIA said:
I have a grid view that is dependent on a textbox. If the user types
the letter 'T' in the textbox, it will find all firstnames that begin
with that letter.
If the user types nothing in that textbox, He should find all names,
no matter what they start with.
The gridview is also dependent on some checkboxes. The asp.net
parameter calls these boolean, and in my storedprocedure (that fills
the grid) I call them 'bit'.
I'm finding that the gridview will populate only if I enter at least
one letter in the textbox. If I leave it blank, the gridview does not
populate. In fact, it looks like the stored procedure does not even
get to the first line when this happens.
The relevant parts of the stored procedure look like this:
ALTER PROCEDURE [dbo].[FillFormHistoryGrid]
@FirstName varchar(20) ='',
@LastName varchar(25) = '',
@IncludeApprovals bit = 0,
@IncludeDenials bit = 0,
@IncludeNoDecision bit = 0,
@StartDate datetime, @EndDate datetime, @Agency varchar(50)
AS
BEGIN
FROM MyTable
Where (len(@FirstName) = 0 or fname like @FirstName + '%') and
(len(@LastName) = 0 or lname like @LastName + '%') and

Has anyone run into this before?
Thanks,
Marv

Since we can't see your code the one thing I can think of is:

What is the trigger for typing nothing?

Do you mean that when the page loads , since there is no text in the textbox
it should show all names?

Are you using AJAX?

LS
 
W

WISEMANOFNARNIA

I have a grid view that is dependent on a textbox.  If the user types
the letter 'T' in the textbox, it will find all firstnames that begin
with that letter.
If the user types nothing in that textbox, He should find all names,
no matter what they start with.
The gridview is also dependent on some checkboxes.  The asp.net
parameter calls these boolean, and in my storedprocedure (that fills
the grid) I call them 'bit'.
I'm finding that the gridview will populate only if I enter at least
one letter in the textbox.  If I leave it blank, the gridview does not
populate.  In fact, it looks like the stored procedure does not even
get to the first line when this happens.
The relevant parts of the stored procedure look like this:
ALTER PROCEDURE [dbo].[FillFormHistoryGrid]
@FirstName varchar(20) ='',
@LastName varchar(25) = '',
@IncludeApprovals bit = 0,
@IncludeDenials bit = 0,
@IncludeNoDecision bit = 0,
@StartDate datetime, @EndDate datetime, @Agency varchar(50)
AS
BEGIN
FROM        MyTable
Where (len(@FirstName) = 0 or fname like @FirstName + '%') and
(len(@LastName) = 0 or lname like @LastName + '%') and
Has anyone run into this before?
Thanks,
Marv

Since we can't see your code the one thing I can think of is:

What is the trigger for typing nothing?

Do you mean that when the page loads , since there is no text in the textbox
it should show all names?

Are you using AJAX?

LS

I found the problem. You cannot run a sqlDataSource that has a
parameter that is based on a control that can be empty, unless you set
a certain property of the sqldatasource to false. I don't have my
code here, and I forgot the name of the property, but that is the
explanation. I'm surprised I never came across this in my readings on
asp.net.
-- Marv
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top