User Controls, passing data
I'm currently working on an ASP.NET application. I have a mainpage.aspx that contains a table control. This table control contains 4 user controls. One of the user controls (UCSearch) contains a dropdownlist that the user selects from. Depending on the selection in this dropdownlist, 1 of 2 other user controls are enabled. In the code behind for the usercontrol (UCCase) that becomes enabled I need to check the value of the dropdownlist on the UCSearch . I am having problems referencing this value. I receive an error of: Referenced object UCSearch has a value of Nothing.
In UCCase I have:
Private UCSearch_ As UCSearch
And then to retreive the value:
If UCSearch_.ddlSearchResults.Items.Count <> 0 Then
This is the line that has the value of nothing. It seems like I'm missing saomething very simple on this but I'm unsure of what it is. Can anyone please help me out???
Thanks,
Corinne
Re: User Controls, passing data
I believe in the user control you have to have property methods to get and set the properties on the control.
So in the user control you would have to have:
Public Property ddlSearchResultsCount() as integer
Get
Return ddlSearchResults.Items.Count
End Get
End Property
Then you would just call UCSearch_.ddSearchResultsCount to retrieve that value.