DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

trying to reference my user controls properties?

This is a discussion on trying to reference my user controls properties? within the .Net Development forums, part of the Programming & Scripting category; Hi I have a user control in a repeater. in my repeaters OnItemDataBound event, i check to see if I ...

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

  #1  
Old October 2nd, 2008, 10:19 AM
Shem's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 292
Rep Power: 2
Shem is on a distinguished road
Default trying to reference my user controls properties?

Hi

I have a user control in a repeater.
in my repeaters OnItemDataBound event, i check to see if I must
set the control to be visible, and at the same time need to set a property
of that control, which I can only do in the code-behind

my repeater and user control:
Code:
<asp:Repeater ID="rpActiveSpecification" runat="server">
                                                                                <ItemTemplate>
                                                                                    <tr>
                                                                                        <td>
                                                                                            <asp:Panel ID="pnlActiveSpecificationForms" runat="server">
                                                                                                <forms:art ID="FormsArt" runat="server" Visible="false" />
                                                                                            </asp:Panel>
                                                                                        </td>
                                                                                    </tr>
                                                                                </ItemTemplate>
                                                                            </asp:Repeater>
my OnItemDataBound: (red)
Code:
Protected Sub rpActiveSpecification_OnItemDataBound(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            '---------------------------------------
            Dim myForms As Forms = e.Item.DataItem

            '---------------------------------------
            Select Case myForms.Name
                Case "Art"
                    Dim FormsArt As UserControl = e.Item.FindControl("FormsArt")
                Case "Carpet Rug"
                   
                Case "Accessories"
                    
                Case "Bedding"
                    
                Case "Casegoods"
                   
                Case "Drapery"
                    
                Case "Fabric"
                    
                Case "Lighting"
                   
                Case "Mirrors"
                    
                Case "Pillow"
                    
                Case "Trims"
                    
                Case "Uplholstered"
                    
                Case "Architectural Schedule"
                   
            End Select
        End If
    End Sub
The property i'm trying to set is 'SpecID'.
when i loaded the controls dynamically I could set the property?

My user controls are all registered in my web.config.

Shem
Reply With Quote
  #2  
Old October 2nd, 2008, 11:41 AM
Wolffy's Avatar
Wolfmaster
 
Join Date: Mar 2008
Real name: Wolff
Location: Peoria, IL
Posts: 779
Blog Entries: 1
Rep Power: 9
Wolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to beholdWolffy is a splendid one to behold
Default

I assume your user control inherits from the UserControl class; in which case you will need to cast the object returned from the FindControl method to your user control class rather than the UserControl class. That should make your property visible.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.
Reply With Quote
  #3  
Old October 3rd, 2008, 02:12 AM
Shem's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 292
Rep Power: 2
Shem is on a distinguished road
Default

Hi Wolfy

I think I understand what your saying, this is what i have now:
Code:
Dim FormsArt As CustomControls_form_art = e.Item.FindControl("FormsArt")
FormsArt.SpecID = myParams.SpecID
FormsArt.Visible = True
This way does see my property SpecID.
'CustomControls_form_art' is my controls Class name.

Shem
Reply With Quote
  #4  
Old October 3rd, 2008, 04:06 AM
Shem's Avatar
Barn Enthusiast
 
Join Date: Mar 2008
Posts: 292
Rep Power: 2
Shem is on a distinguished road
Default

it seems to be working now Wolfy
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


Similar Threads

Thread Thread Starter Forum Replies Last Post
[ASP.Net - VB.Net] Declare and add Custom Controls programmatically to a panel Shem .Net Development 4 September 22nd, 2008 10:55 AM
Accessing controls in the Footer of a datalist richyrich .Net Development 6 May 12th, 2008 12:19 PM
[Feedback] User Title Suggestions jmurrayhead Suggestions & Feedback 15 March 21st, 2008 12:54 PM


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


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2