taz8020
asked on
ASP.NET How you use access a vaule used on the main form, from within a user control
Hi I have a user control within a web page. The page is filled with data using the sqldatasource.
On the main page I am using Text='<%# Eval("ShortDescription") %>'
And from within the usercontrol on the same page I want to be able to get the ShortDescription on the parent page.
I know i could probable do this using varibles but there must be an easy way!!!
On the main page I am using Text='<%# Eval("ShortDescription") %>'
And from within the usercontrol on the same page I want to be able to get the ShortDescription on the parent page.
I know i could probable do this using varibles but there must be an easy way!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use the following
Dim MyLabel As Label = FormView1.Findcontrol("Pro ductTable" ).FindCont rol("Label Desc")
Remember to add error handling
Dim MyLabel As Label = FormView1.Findcontrol("Pro
Remember to add error handling
ASKER
CodeCruiser, Once again thank you. Just to finish I now see how both work. Which would you say is best
using:
Public ReadOnly Property ProductDescpription() As String
Get
Return _ProductDescpription
End Get
End Property
Or
Dim MyLabel As Label = FormView1.FindControl("Lab elDesc")
Session("ProductDescpripti on") = MyLabel.Text
using:
Public ReadOnly Property ProductDescpription() As String
Get
Return _ProductDescpription
End Get
End Property
Or
Dim MyLabel As Label = FormView1.FindControl("Lab
Session("ProductDescpripti
You are welcome.
Both approaches are fine. With the second approach, you would need to add error handling to make sure that a label is found before you try to access it.
Both approaches are fine. With the second approach, you would need to add error handling to make sure that a label is found before you try to access it.
ASKER
My problem is my label Called 'LabelDesc' is in a table Called 'ProductTable' which is in a form called 'formview1'
How do i access it? and which out of the 3 options is best?
Session("ProductDescpripti
Session("ProductDescpripti
Dim MyLabel as Label = CType(webcontrol.findcontr
Please help.