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 ...
| |||||||
|
#1
| ||||
| ||||
| 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>
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
when i loaded the controls dynamically I could set the property? My user controls are all registered in my web.config. Shem |
|
#2
| ||||
| ||||
| 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. |
|
#3
| ||||
| ||||
| 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
'CustomControls_form_art' is my controls Class name. Shem |
|
#4
| ||||
| ||||
| it seems to be working now Wolfy |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 |