Pasing an ICollection to a usercontrol

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

  1. Jamil Zahoor

    Jamil Zahoor Guest

    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

    Guest Guest

    I believe ICollections can be added to either the ViewState
    Look into how to add and retrieve items from the ViewState and see if that
    fits what you need.
    something ridiculously simple to be followed could be using this in your
    OnLoad
    if (ViewState["DataAction"]!=null)

    {

    DataAction = (DataActions) ViewState["DataAction"];

    }

    else

    {

    ViewState.Add("DataAction", DataAction);

    }


    and then override your Render method and ViewState.Add("...", value) ; You
    do it in the Render to make sure that if you change the item that it the
    latest version is saved.

    Hope some of these tips help


    View
    "Jamil Zahoor" <> wrote in message
    news:12bb01c5146b$b76876a0$...
    >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
    >
    Guest, 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. Scott
    Replies:
    2
    Views:
    411
    John Saunders
    Aug 12, 2003
  2. Janus Knudsen

    method type ICollection returns Dataview

    Janus Knudsen, Jul 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,827
    Natty Gur
    Jul 6, 2004
  3. stephen b
    Replies:
    14
    Views:
    509
  4. Jamil Zahoor

    Passing an ICollection object to a UserControl

    Jamil Zahoor, Feb 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    113
    Jamil Zahoor
    Feb 17, 2005
  5. Dave Lilley
    Replies:
    22
    Views:
    261
    Marnen Laibow-Koser
    Jan 1, 2010
Loading...

Share This Page