Web User Controls - How to reference objects on them?

  • Thread starter Thread starter Hanover
  • Start date Start date
H

Hanover

What I want to do seems like it should be simple:

1. Create a new web control

2. Place a datagrid on it and set it's ID to dgFiles

3. Assign it's datasource.

Sub ShowFiles()

Dim ds as dataset

....code here...

dgFiles.DataSource = ds

End Sub

When I assign it's datasource, it is saying dgFiles is not set to
anything which is stupid since intellisense is acting like it's there
and ready to be used.

So how do I reference to a control on my Web User Control?
 
Are you trying to set is datasource on the aspx page that has the
control? If so, make the datagrid a public member of the control
instead of protected.
 
are you doing this in the control or the page containing the control?
From the controls codebehind you should easily be able to do it, from the
page you will have to do some extra work.
 
Back
Top