Accessing Datagrid properties within a user control from the outside

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
 
C

Craig G

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
 
C

Craig G

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,477
Members
44,898
Latest member
BlairH7607

Latest Threads

Top