Pasing an ICollection to a usercontrol

J

Jamil Zahoor

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
 
G

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top