Accessing Datagrid properties within a user control from the outside

  • Thread starter Thread starter Craig G
  • Start date Start date
C

Craig G

i have a user control which is basically a datagrid, which has
add/edit/delete buttons on the grid

is there anyway of accessing the actual datagrid from the form itself?

basically i want to set the add/edit/delete options visble/invisible on the
datagrid depending on the users's role, but found that i cannot access the
grid to do this.

is the only way of setting it in the page load of the usercontrol itself?

Cheers,
Craig
 
cheers for that.

so in the user control its just a case of saying something like this?

Public Property SetDelete()

Get
return DataGrid1.Columns(0).Visible
End Get

Set(ByVal Value)
DataGrid1.Columns(0).Visible = Value
End Set

End Property

then in the code behind of the page, something like this?


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim myUC As New WebUserControl2
myUC.SetDelete = False
End Sub


when i do this i get an error in the ascx saying objectReference not set to
an instance of an obejct, and it is falling over in the following line

DataGrid1.Columns(0).Visible = Value

Cheers,
Craig
 
sorry...my fault

didnt realise when you declare the object in the code behind that it must
use the same ID as the usercontrol on the screen
 
Back
Top