Gridview - check select parameter

Discussion in 'ASP .Net' started by Tony WONG, Dec 14, 2009.

  1. Tony WONG

    Tony WONG Guest

    the gridview is filtered by a textbox

    when the user inputs 2009-1782 in the textbox

    then the gridview shows the record numbered 1782

    String before hypen is irrelevant, then a button event is used to erase
    "2009-" in the textbox
    ***********
    If InStr(SearchNo.Text, "-") = True Then
    SearchNo.Text = Right(SearchNo.Text, len(SearchNo)-5)
    GridView1.DataBind()
    End If
    ************

    but page error, it seems select command fires before change of textbox

    What's the best way to do validating select parameters for the gridview?

    Thanks a lot.

    tony
     
    Tony WONG, Dec 14, 2009
    #1
    1. Advertising

  2. On Dec 14, 9:49 am, "Tony WONG" <> wrote:
    > the gridview is filtered by a textbox
    >
    > when the user inputs 2009-1782 in the textbox
    >
    > then the gridview shows the record numbered 1782
    >
    > String before hypen is irrelevant, then a button event is used to erase
    > "2009-" in the textbox
    > ***********
    >         If InStr(SearchNo.Text, "-") = True Then
    >             SearchNo.Text = Right(SearchNo.Text, len(SearchNo)-5)
    >             GridView1.DataBind()
    >         End If
    > ************
    >
    > but page error, it seems select command fires before change of textbox
    >
    > What's the best way to do validating select parameters for the gridview?
    >
    > Thanks a lot.
    >
    > tony


    Hi Tony,

    I believe that the error is about type mismatch. First of all, InStr
    returns integer and not boolean, change to

    If InStr(SearchNo.Text, "-") > -1 Then

    then change len(SearchNo)

    to len(SearchNo.Text)

    Hope this helps
     
    Alexey Smirnov, Dec 14, 2009
    #2
    1. Advertising

  3. Tony WONG

    Tony WONG Guest

    Thanks a lot. Alexey

    "Alexey Smirnov" <>
    ???????:...
    On Dec 14, 9:49 am, "Tony WONG" <> wrote:
    > the gridview is filtered by a textbox
    >
    > when the user inputs 2009-1782 in the textbox
    >
    > then the gridview shows the record numbered 1782
    >
    > String before hypen is irrelevant, then a button event is used to erase
    > "2009-" in the textbox
    > ***********
    > If InStr(SearchNo.Text, "-") = True Then
    > SearchNo.Text = Right(SearchNo.Text, len(SearchNo)-5)
    > GridView1.DataBind()
    > End If
    > ************
    >
    > but page error, it seems select command fires before change of textbox
    >
    > What's the best way to do validating select parameters for the gridview?
    >
    > Thanks a lot.
    >
    > tony


    Hi Tony,

    I believe that the error is about type mismatch. First of all, InStr
    returns integer and not boolean, change to

    If InStr(SearchNo.Text, "-") > -1 Then

    then change len(SearchNo)

    to len(SearchNo.Text)

    Hope this helps
     
    Tony WONG, Dec 15, 2009
    #3
  4. On Dec 15, 9:11 am, "Tony WONG" <> wrote:
    > Thanks a lot.  Alexey
    >
    > "Alexey Smirnov" <>
    > ???????:....
    > On Dec 14, 9:49 am, "Tony WONG" <> wrote:
    >
    >
    >
    >
    >
    > > the gridview is filtered by a textbox

    >
    > > when the user inputs 2009-1782 in the textbox

    >
    > > then the gridview shows the record numbered 1782

    >
    > > String before hypen is irrelevant, then a button event is used to erase
    > > "2009-" in the textbox
    > > ***********
    > > If InStr(SearchNo.Text, "-") = True Then
    > > SearchNo.Text = Right(SearchNo.Text, len(SearchNo)-5)
    > > GridView1.DataBind()
    > > End If
    > > ************

    >
    > > but page error, it seems select command fires before change of textbox

    >
    > > What's the best way to do validating select parameters for the gridview?

    >
    > > Thanks a lot.

    >
    > > tony

    >
    > Hi Tony,
    >
    > I believe that the error is about type mismatch. First of all, InStr
    > returns integer and not boolean, change to
    >
    > If InStr(SearchNo.Text, "-") > -1 Then
    >
    > then change len(SearchNo)
    >
    > to len(SearchNo.Text)
    >
    > Hope this helps- Hide quoted text -
    >
    > - Show quoted text -


    Glad it helps. It always useful to see what error message system
    returns. In most cases a message tells exactly what the problem is. If
    you have just "an application error" then set customErrors mode to Off

    http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx
     
    Alexey Smirnov, Dec 15, 2009
    #4
    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. =?Utf-8?B?RGFiYmxlcg==?=

    select gridview row without using select button?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 3, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    101,573
    dch31969
    Feb 27, 2009
  2. Managed Code
    Replies:
    0
    Views:
    3,655
    Managed Code
    Jun 14, 2006
  3. Managed Code
    Replies:
    0
    Views:
    231
    Managed Code
    Jun 14, 2006
  4. palmiere
    Replies:
    1
    Views:
    431
    Erwin Moller
    Feb 9, 2004
  5. Suresh
    Replies:
    2
    Views:
    409
    Suresh
    Apr 22, 2004
Loading...

Share This Page