Results 1 to 4 of 4

Thread: Event handler

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2016
    Posts
    7

    Event handler

    I use this code to obtain a selected data from GridView control.
    I created a user control and reference it to ASPX page.
    However, for some reason I can not access public methods IndexChanged to retrieve information of selected line.
    What is wrong in the code?
    *
    User controls:
    *
    Public gridRow As GridViewRow
    Public Event IndexChanged As GridViewSelectEventHandler
    *
    Protected Sub GridView_SelectedIndexChanged (sender As Object, e As EventArgs) Handles gv.SelectedIndexChanged
    ******* gridRow = Grid.SelectedRow
    ******* RaiseEvent IndexChanged (sender, e)
    End Sub
    *
    ASPX page:
    *
    *
    grid.IndexChanged - there is no such event in the selection (the grid is the name of the user control)

  2. #2
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Re: Event handler

    Well firstly if Grid is the actual name of your control then surely you should be doing -

    Code:
    Handles grid.SelectedIndexChanged
    and not
    Code:
    Handles gv.SelectedIndexChanged
    One thing though, when you say User Control, do you mean you added a Grid Control to the page? or you created your own User Control and added that to your page?
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2016
    Posts
    7

    Re: Event handler

    Quote Originally Posted by NeedSomeAnswers View Post
    Well firstly if Grid is the actual name of your control then surely you should be doing -

    Code:
    Handles grid.SelectedIndexChanged
    and not
    Code:
    Handles gv.SelectedIndexChanged
    One thing though, when you say User Control, do you mean you added a Grid Control to the page? or you created your own User Control and added that to your page?
    I created my own user control.
    gv is the name of grid in user control.

    grid is one web page.

  4. #4
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,657

    Re: Event handler

    Ahh, that is your problem then, the Grid events wont be exposed unless you expose them.

    When your using a predefined control such as a Grid it has events already exposed, when you create your own User Control you need to expose all the events you want to interact with yourself, it is not automatic, and the Grid itself wont be accessible externally either.

    Essentially you need to create your own Events for your User Control.
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width