Gridview will not populate unless I type letters in a textbox

Discussion in 'ASP .Net' started by WISEMANOFNARNIA, Nov 25, 2008.

  1. 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
     
    WISEMANOFNARNIA, Nov 25, 2008
    #1
    1. Advertising

  2. WISEMANOFNARNIA

    Lloyd Sheen Guest

    "WISEMANOFNARNIA" <> wrote in message
    news:...
    >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
     
    Lloyd Sheen, Nov 25, 2008
    #2
    1. Advertising

  3. On Nov 25, 2:24 pm, "Lloyd Sheen" <> wrote:
    > "WISEMANOFNARNIA" <> wrote in message
    >
    > news:...
    >
    >
    >
    > >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
     
    WISEMANOFNARNIA, Nov 27, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pablo

    Numbers or letters in a TextBox

    Pablo, Aug 26, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    406
    Jerry III
    Aug 26, 2003
  2. Merrigan
    Replies:
    4
    Views:
    575
    Chris
    Dec 14, 2007
  3. Enjoy Life
    Replies:
    2
    Views:
    280
    Roland Hall
    Feb 23, 2005
  4. Gábor SEBESTYÉN

    Unless unless

    Gábor SEBESTYÉN, Jun 17, 2005, in forum: Ruby
    Replies:
    3
    Views:
    154
    Gábor SEBESTYÉN
    Jun 17, 2005
  5. Venugopal
    Replies:
    11
    Views:
    1,536
    Tassilo v. Parseval
    Nov 5, 2003
Loading...

Share This Page