DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

Reference User Control in nested repeater

This is a discussion on Reference User Control in nested repeater within the .Net Development forums, part of the Programming & Scripting category; Hi again the scenario: my user control is loaded into a ModalPopupExtender via OnItemDataBound of a repeater sitting in the ...

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

  1 links from elsewhere to this Post. Click to view. #1  
Old October 3rd, 2008, 03:57 AM
Shem's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 292
Rep Power: 2
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
  #2  
Old October 3rd, 2008, 07:43 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,964
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
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.

If you like it here...throw us a few bones to help
support us.

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: 292
Rep Power: 2
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
Real name: Jason
Location: Washington, D.C.
Posts: 1,964
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
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


LinkBacks (?)

LinkBack to this Thread: http://www.developerbarn.com/net-development/643-reference-user-control-nested-repeater.html

Posted By For Type Date
How to find a usercontrol in a Repeater - ASP.NET Forums This thread Refback October 14th, 2009 05:31 PM

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 05:13 PM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2