Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

Sponsored Links

Discuss "Reference User Control in nested repeater" in the .Net Development forum.

.Net Development - Learn about the Microsoft.Net framework and how to create powerful web-based (ASP.net) and client-based (Windows Forms) applications utilizing various languages such as C#, VB.Net, J# and others.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1  
Old October 3rd, 2008, 03:57 AM
Shem's Avatar
Barn Enthusiast

 
Join Date: Mar 2008
Posts: 261
Thanks: 30
Thanked 5 Times in 5 Posts
Rep Power: 1
Shem is on a distinguished road
Default Reference User Control in nested repeater

Hi again

the scenario:
my user control is loaded into a ModalPopupExtender via OnItemDataBound of
a repeater sitting in the diaplay Panel of the ModalPopup.

inside that panel is an update button which fires an event, which in turn fires
an update event in my user control's code-behind.

All of this is happening within a nested repeater (grandchild), and this is what
makes it difficult to reference controls etc.

here's my logic:
the sender is the 'Update Button'
from there I can reference the Panel the button resides in
from there I can reference the Repeater that resides in the Panel.

this all works, so from there I wanted to reference my UserControl that
was in the repeater, but alas it doesn't find my UserControl.

my code for the Update event of my Update Button:
green = works
red = doesn't work
Code:
Public Sub ActiveSpecificationsUpdate(ByVal sender As Object, ByVal e As EventArgs)
        Dim myButton As Button = sender
        Dim pnlActiveSpecification As Panel = myButton.Parent
        Dim rpActiveSpecification As Repeater = pnlActiveSpecification.FindControl("rpActiveSpecification")
        If CType(ViewState("FormsArt"), String) = "1" Then
            Dim FormsArt As CustomControls_form_art = rpActiveSpecification.FindControl("FormsArt")
            FormsArt.SpecID = myParams.SpecID
            FormsArt.Visible = True
            FormsArt.Update_Form()
            ViewState("FormsArt") = "0".ToString()
        End If
    End Sub
any ideas?
Shem
Reply With Quote
Sponsored Links
  #2  
Old October 3rd, 2008, 07:43 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 820
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

You will need to search through the repeater items to find your user control. If the user control is in the same repeater item as the button that you clicked:

Code:
Public Sub ActiveSpecificationsUpdate(ByVal sender As Object, ByVal e As EventArgs)
    Dim btn As Button = sender
    Dim FormsArt As CustomControls_form_art = btn.Parent.FindControl("FormsArt")
End Sub
Or, you can try iterating through the repeater items:

Code:
Public Sub ActiveSpecificationsUpdate(ByVal sender As Object, ByVal e As EventArgs)
    For Each item As RepeaterItem in Repeater1.Items
        Dim FormsArt As CustomControls_form_art = TryCast(item.FindControl("FormsArt"), CustomControls_form_art)
    Next
End Sub

Comments on this post
Shem agrees: Thanked Post
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
The Following User Says Thank You to jmurrayhead For This Useful Post:
Shem (October 7th, 2008)
  #3  
Old October 7th, 2008, 05:23 AM
Shem's Avatar
Barn Enthusiast

 
Join Date: Mar 2008
Posts: 261
Thanks: 30
Thanked 5 Times in 5 Posts
Rep Power: 1
Shem is on a distinguished road
Default

You effing Genius.....

this totally worked:
Code:
Public Sub ActiveSpecificationsUpdate(ByVal sender As Object, ByVal e As EventArgs)
    For Each item As RepeaterItem in Repeater1.Items
        Dim FormsArt As CustomControls_form_art = TryCast(item.FindControl("FormsArt"), CustomControls_form_art)
    Next
End Sub
Thanx alot dude, can't believe i only tried this now
Shem
Reply With Quote
  #4  
Old October 7th, 2008, 07:23 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 820
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

Cheers Glad I could help
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Thread Tools
Display Modes

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 On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to reference my user controls properties? Shem .Net Development 3 October 3rd, 2008 04:06 AM
Dynamically added user control, not getting it's values Shem .Net Development 11 October 2nd, 2008 08:41 AM
Object Reference Error on Custom Control Postback richyrich .Net Development 1 September 22nd, 2008 05:56 PM
[ASP.Net - Web Controls] reference control from nested repeater Shem .Net Development 18 September 15th, 2008 10:46 AM
paging enabled in a repeater control peebman2000 .Net Development 6 September 4th, 2008 11:15 AM


All times are GMT -4. The time now is 04:04 PM.



Content Relevant URLs by vBSEO 3.2.0