Passing an ICollection object to a UserControl

J

Jamil Zahoor

-- 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
 
J

Jamil Zahoor

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
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top