Gridview and Empty Textbox .net 2.0

Discussion in 'ASP .Net' started by paulmac106, Jan 8, 2006.

  1. paulmac106

    paulmac106 Guest

    Hi,

    I have a gridview based on a SQL stored procedure. I then want to let
    the user filter the results by 4 textboxes. When all 4 textboxes have
    "some" search criteria the gridview works fine, but if even one is left
    blank the gridview doesn't return any records. When I test the stored
    procedure itself it works fine. Can you help me work with the empty
    textboxes.

    thanks,
    Paul
    paulmac106, Jan 8, 2006
    #1
    1. Advertising

  2. paulmac106

    Hans Kesting Guest

    Re: =?UTF-8?B?R3JpZHZpZXcgYW5kIEVtcHR5IFRleHRib3ggLm5ldCAyLjA=?=

    > Hi,
    >
    > I have a gridview based on a SQL stored procedure. I then want to let
    > the user filter the results by 4 textboxes. When all 4 textboxes have
    > "some" search criteria the gridview works fine, but if even one is left
    > blank the gridview doesn't return any records. When I test the stored
    > procedure itself it works fine. Can you help me work with the empty
    > textboxes.
    >
    > thanks,
    > Paul


    What will the query be when you have empty textboxes?
    How did you test the stored procedure?

    An empty textbox will have an "empty string" as value, not "null",
    maybe that's the problem.

    Can you use SqlProfiler to check what is executed in SqlServer?

    Hans Kesting
    Hans Kesting, Jan 9, 2006
    #2
    1. Advertising

  3. paulmac106

    pato

    Joined:
    Sep 20, 2006
    Messages:
    1
    Workaround

    I had the same problem. SQL Profiler showed me that the SQL Server was not called to execute any instruction if the textbox was empty.
    Here is a workaround:
    1. Add DefaultValue=" " (the space char) to the textbox definition. For instance, let´s call the textbox name attribute to "cara".
    2. Change the query string:
    "select * from notas where charindex(@cara,caratula)=1" was supposed to return all records where the field caratula started with the value of cara.
    Now, it must read:
    "select * from notas where charindex(ltrim(@cara),caratula)=1"

    It seems that ASP.Net needs all fields to have some value to launch the query execution.

    Hope this helps,

    Pato.
    Last edited: Sep 20, 2006
    pato, Sep 20, 2006
    #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. Marcia Hon

    Check if a directory is empty and empty it

    Marcia Hon, Feb 8, 2004, in forum: C Programming
    Replies:
    8
    Views:
    564
    Dave Thompson
    Feb 14, 2004
  2. ButlerDJIAM
    Replies:
    0
    Views:
    546
    ButlerDJIAM
    Nov 9, 2006
  3. Tzury Bar Yochay
    Replies:
    1
    Views:
    394
    Gabriel Genellina
    Mar 24, 2008
  4. Savvoulidis Iordanis

    Empty gridview cells and checking for empty string

    Savvoulidis Iordanis, Sep 5, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    508
    Savvoulidis Iordanis
    Sep 5, 2008
  5. Yingjie Lan

    empty set and empty dict for Python 3

    Yingjie Lan, Jul 15, 2010, in forum: Python
    Replies:
    1
    Views:
    248
    Peter Otten
    Jul 15, 2010
Loading...

Share This Page