Button click & filtering a GridView

Discussion in 'ASP .Net' started by Jokke, Apr 2, 2010.

  1. Jokke

    Jokke Guest

    Hi,

    * Click event doesn't fire?

    On clicking a button, my gridview should be filtered with the value typed in
    a textbox.

    It works, but only the second time you click the button. First click ->
    nothing.

    To be on the safe side, I already removed the button and put another one
    there (with other name), but the behavior still stands.

    I am a first timer in ASP.NET, so I must be missing something. I tried
    debugging, and the click event simply doesn't fire the first time you click
    the button... Please advise!

    the code is:

    Protected Sub btnFilterSupplName_Click(ByVal sender As Object, ByVal e
    As System.EventArgs) Handles btnFilterSupplName.Click
    SqlDataSource2.FilterExpression = "[SupplierName] LIKE '%" &
    Me.txtSearchSupplName.Text & "%'"
    Me.GridView1.DataBind()
    End Sub

    * Selecting the first GridView record

    The GridView has a Select column, and a Details View control is bound to it
    If the textbox/button filtering yields results in the GridView, I would like
    the DetailsView to display the first record in the GridView, as if the user
    had clicked on the Select of the first GridView record.
    How can I do this?

    thank you for your help!
     
    Jokke, Apr 2, 2010
    #1
    1. Advertising

  2. Can you post the code where you are telling the button about this event
    handler? For example, are you setting Click="btnFilterSupplName_Click" in
    the HTML markup or are you maybe doing this in a Page Load event, etc...


    "Jokke" <> wrote in message
    news:...
    > Hi,
    >
    > * Click event doesn't fire?
    >
    > On clicking a button, my gridview should be filtered with the value typed
    > in a textbox.
    >
    > It works, but only the second time you click the button. First click ->
    > nothing.
    >
    > To be on the safe side, I already removed the button and put another one
    > there (with other name), but the behavior still stands.
    >
    > I am a first timer in ASP.NET, so I must be missing something. I tried
    > debugging, and the click event simply doesn't fire the first time you
    > click the button... Please advise!
    >
    > the code is:
    >
    > Protected Sub btnFilterSupplName_Click(ByVal sender As Object, ByVal e
    > As System.EventArgs) Handles btnFilterSupplName.Click
    > SqlDataSource2.FilterExpression = "[SupplierName] LIKE '%" &
    > Me.txtSearchSupplName.Text & "%'"
    > Me.GridView1.DataBind()
    > End Sub
    >
    > * Selecting the first GridView record
    >
    > The GridView has a Select column, and a Details View control is bound to
    > it
    > If the textbox/button filtering yields results in the GridView, I would
    > like the DetailsView to display the first record in the GridView, as if
    > the user had clicked on the Select of the first GridView record.
    > How can I do this?
    >
    > thank you for your help!
     
    James VanDyne, Apr 2, 2010
    #2
    1. Advertising

  3. Jokke

    Jokke Guest

    It is the button click event alright.

    btnFilterSCode_Click

    Actually happens with 2 buttons, on their respective click events...

    Thx for helping.


    "James VanDyne" <> wrote in message
    news:...
    > Can you post the code where you are telling the button about this event
    > handler? For example, are you setting Click="btnFilterSupplName_Click" in
    > the HTML markup or are you maybe doing this in a Page Load event, etc...
    >
    >
    > "Jokke" <> wrote in message
    > news:...
    >> Hi,
    >>
    >> * Click event doesn't fire?
    >>
    >> On clicking a button, my gridview should be filtered with the value typed
    >> in a textbox.
    >>
    >> It works, but only the second time you click the button. First click ->
    >> nothing.
    >>
    >> To be on the safe side, I already removed the button and put another one
    >> there (with other name), but the behavior still stands.
    >>
    >> I am a first timer in ASP.NET, so I must be missing something. I tried
    >> debugging, and the click event simply doesn't fire the first time you
    >> click the button... Please advise!
    >>
    >> the code is:
    >>
    >> Protected Sub btnFilterSupplName_Click(ByVal sender As Object, ByVal e
    >> As System.EventArgs) Handles btnFilterSupplName.Click
    >> SqlDataSource2.FilterExpression = "[SupplierName] LIKE '%" &
    >> Me.txtSearchSupplName.Text & "%'"
    >> Me.GridView1.DataBind()
    >> End Sub
    >>
    >> * Selecting the first GridView record
    >>
    >> The GridView has a Select column, and a Details View control is bound to
    >> it
    >> If the textbox/button filtering yields results in the GridView, I would
    >> like the DetailsView to display the first record in the GridView, as if
    >> the user had clicked on the Select of the first GridView record.
    >> How can I do this?
    >>
    >> thank you for your help!

    >
     
    Jokke, Apr 6, 2010
    #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. Purvi T
    Replies:
    0
    Views:
    864
    Purvi T
    Oct 19, 2004
  2. mike parr
    Replies:
    1
    Views:
    480
    Marina
    May 20, 2004
  3. Ben Fidge
    Replies:
    5
    Views:
    740
    S. Justin Gengo
    Jun 15, 2004
  4. Amy
    Replies:
    0
    Views:
    997
  5. Max2006
    Replies:
    2
    Views:
    1,585
    Walter Wang [MSFT]
    Sep 19, 2007
Loading...

Share This Page