Passing an ICollection object to a UserControl

Discussion in 'ASP .Net Web Controls' started by Jamil Zahoor, Feb 16, 2005.

  1. Jamil Zahoor

    Jamil Zahoor Guest

    -- reposting with valid email

    I have a UserControl (CustomGrid.ascx) that displays a
    DataGrid and contains page navigation with bi-directional
    Sorting. This UserControl has, among other methods and
    properties: (psuedo-code)
    - public spname as string
    - public Sub SetSpName (s as string)
    - lblspname as Label

    spname represents the name of the stored procedure that
    will return the data. I created a Label on the
    CustomGrid.ascx to store this spname between postbacks.

    I'm using CustomGrid.ascx in a search page
    (SearchCompanies.aspx). The search page consists of a
    few TextBoxes to gather search criteria from a user. It
    also contains a Search button.

    I'm traversing through the TextBoxes on the
    SearchCompanies page and building an ICollection that
    contains the SQLParameter objects.

    I need to pass both the spname and the ICollection object
    from SearchCompanies.aspx page to the CustomGrid.ascx
    control upon btnSearch click.

    I can't find an efficient way to have the ICollection
    object persist between postbacks. I've searched the
    internet for answers as well but in vain. I can get the
    first set of results. But when the [Next Page] link on
    the CustomGrid.ascx is clicked, it does a postback and
    forgets the ICollection object that it needs to bind the
    datagrid.

    Any insight would be appreciated.

    Jamil
    Jamil Zahoor, Feb 16, 2005
    #1
    1. Advertising

  2. Jamil Zahoor

    Jamil Zahoor Guest

    I think I figured this out myself, using EventBubbling.
    Basically, I'm raising a bubble event in my
    navigation_click event routine (in CustomGrid.ascx) and
    then capturing it in the parent page
    (SearchCompanies.aspx).

    In my SearchCompanies.aspx page, I capture the event and
    rebind the CustomGrid control.

    I'm open to other suggestions, but this seems to work for
    now. Will be glad to share code upon request...snippets
    below

    Jamil
    CustomGrid.ascx.vb
    Protected Sub NavigationLink_Click(ByVal sender As
    Object, ByVal e As CommandEventArgs)
    ' Do navigation stuff here
    RaiseBubblEevent(Me, e)
    End Sub

    SearchCompanies.aspx.vb
    Protected Overrides Function OnBubbleEvent(ByVal source
    As Object, ByVal e As EventArgs) As Boolean
    Dim handled As Boolean = False
    ucGridCompanies.SetlblSpName("listCompanies")
    ucGridCompanies.SetWheres(SearchSQLParameters)
    ucGridCompanies.BindData()

    Return handled
    End Function


    >-----Original Message-----
    >-- reposting with valid email
    >
    >I have a UserControl (CustomGrid.ascx) that displays a
    >DataGrid and contains page navigation with bi-

    directional
    >Sorting. This UserControl has, among other methods and
    >properties: (psuedo-code)
    >- public spname as string
    >- public Sub SetSpName (s as string)
    >- lblspname as Label
    >
    >spname represents the name of the stored procedure that
    >will return the data. I created a Label on the
    >CustomGrid.ascx to store this spname between postbacks.
    >
    >I'm using CustomGrid.ascx in a search page
    >(SearchCompanies.aspx). The search page consists of a
    >few TextBoxes to gather search criteria from a user. It
    >also contains a Search button.
    >
    >I'm traversing through the TextBoxes on the
    >SearchCompanies page and building an ICollection that
    >contains the SQLParameter objects.
    >
    >I need to pass both the spname and the ICollection

    object
    >from SearchCompanies.aspx page to the CustomGrid.ascx
    >control upon btnSearch click.
    >
    >I can't find an efficient way to have the ICollection
    >object persist between postbacks. I've searched the
    >internet for answers as well but in vain. I can get the
    >first set of results. But when the [Next Page] link on
    >the CustomGrid.ascx is clicked, it does a postback and
    >forgets the ICollection object that it needs to bind the
    >datagrid.
    >
    >Any insight would be appreciated.
    >
    >Jamil
    Jamil Zahoor, Feb 17, 2005
    #2
    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. Janus Knudsen

    method type ICollection returns Dataview

    Janus Knudsen, Jul 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,836
    Natty Gur
    Jul 6, 2004
  2. HP
    Replies:
    1
    Views:
    1,609
    =?Utf-8?B?RG90TmV0SmVyb21l?=
    Feb 26, 2005
  3. Pinkesh
    Replies:
    0
    Views:
    333
    Pinkesh
    Jan 12, 2007
  4. Polaris431
    Replies:
    2
    Views:
    486
    Chris Dollin
    Nov 9, 2006
  5. Jamil Zahoor

    Pasing an ICollection to a usercontrol

    Jamil Zahoor, Feb 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    144
    Guest
    Feb 17, 2005
Loading...

Share This Page