Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Passing an ICollection object to a UserControl

Reply
Thread Tools

Passing an ICollection object to a UserControl

 
 
Jamil Zahoor
Guest
Posts: n/a
 
      02-16-2005
-- 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
 
Reply With Quote
 
 
 
 
Jamil Zahoor
Guest
Posts: n/a
 
      02-17-2005
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot add property into Class when implementing ICollection interface Pinkesh ASP .Net 0 01-12-2007 10:30 AM
How do you reference this property: System.Collections.Generic.ICollection<DataSource> Polaris431 C Programming 2 11-09-2006 11:08 AM
DataGrid Paging / ICollection Error [JSCRIPT] HP ASP .Net 1 02-26-2005 10:01 AM
Pasing an ICollection to a usercontrol Jamil Zahoor ASP .Net Web Controls 1 02-17-2005 04:41 PM
method type ICollection returns Dataview Janus Knudsen ASP .Net 1 07-06-2004 06:04 AM



Advertisments