Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Accessing Datagrid properties within a user control from the outside

Reply
Thread Tools

Accessing Datagrid properties within a user control from the outside

 
 
Craig G
Guest
Posts: n/a
 
      11-30-2004
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


 
Reply With Quote
 
 
 
 
=?Utf-8?B?SGVybWl0IERhdmU=?=
Guest
Posts: n/a
 
      11-30-2004
Craig,

You can define method and properties for your user control exposing whatever
you wish to with the desired scope.

ie have a public property say Button1Visible which internally sets the value
of the button 1 of your user control... have a look the link below to see how
you can access method and properties of user control from within aspx page

http://www.dotnetjunkies.com/Article...F720AB013.dcik

"Craig G" wrote:

> 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
>
>
>

 
Reply With Quote
 
 
 
 
Craig G
Guest
Posts: n/a
 
      11-30-2004
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




"Hermit Dave" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Craig,
>
> You can define method and properties for your user control exposing

whatever
> you wish to with the desired scope.
>
> ie have a public property say Button1Visible which internally sets the

value
> of the button 1 of your user control... have a look the link below to see

how
> you can access method and properties of user control from within aspx page
>
>

http://www.dotnetjunkies.com/Article...F720AB013.dcik
>
> "Craig G" wrote:
>
> > 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
> >
> >
> >



 
Reply With Quote
 
Craig G
Guest
Posts: n/a
 
      11-30-2004
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

"Craig G" <(E-Mail Removed)> wrote in message
news:%23Ax8%(E-Mail Removed)...
> 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
>
>
>
>
> "Hermit Dave" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Craig,
> >
> > You can define method and properties for your user control exposing

> whatever
> > you wish to with the desired scope.
> >
> > ie have a public property say Button1Visible which internally sets the

> value
> > of the button 1 of your user control... have a look the link below to

see
> how
> > you can access method and properties of user control from within aspx

page
> >
> >

>

http://www.dotnetjunkies.com/Article...F720AB013.dcik
> >
> > "Craig G" wrote:
> >
> > > 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
> > >
> > >
> > >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with pix inside->outside + dmz->outside + inside->outside->dmz Jack Cisco 0 09-19-2007 01:57 AM
Designer Support: How to have user control's properties appear in IDE's properties window? Max2006 ASP .Net 2 07-13-2007 01:45 PM
User control accessing outside control tshad ASP .Net 3 05-19-2006 03:34 PM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr ASP .Net 0 03-22-2006 08:02 AM
Accessing a parent web form control from within a nested user control? Roy ASP .Net 1 02-10-2005 07:09 PM



Advertisments