Dynamic ReadOnly in DetailsView
Dynamic ReadOnly in DetailsView
am 29.10.2007 17:42:04 von MikeD
I need to dynamically set the ReadOnly value in a BoundField in a
DetailsView. The DetailsView is generated from a GridView selection and has
both Edit and New buttons. I need to be able to set the readonly property on
one of the fields depending on the user's group. I have tried to access the
property by Detailsview1.Fields[3].Readonly and by
Detailsview1.FindControl("Dept").Readonly but neither exist. Is it even
possible to set the readonly property of a BoundField in the code-behind?
--
Regards,
Mike D
Coding in C# since Feb 2007
RE: Dynamic ReadOnly in DetailsView
am 15.01.2008 00:45:03 von rodoopus
Yes Mike! I do that routinely... But it also depends. I do not relie on any
declarative stuff or Datasouce cotrols so I completely bound my control
programmatically.
In my column definition I do the following
' category id
bf = New boundField
bf.DataField="CategoryID"
bf.HeaderText = "Category ID"
bf.ReadOnly = True ' This could be of course done dynamically at this point
detailsView1.Fields.add(bf)
I tested this before answering you and it works.
--
aaa
"Mike D" wrote:
> I need to dynamically set the ReadOnly value in a BoundField in a
> DetailsView. The DetailsView is generated from a GridView selection and has
> both Edit and New buttons. I need to be able to set the readonly property on
> one of the fields depending on the user's group. I have tried to access the
> property by Detailsview1.Fields[3].Readonly and by
> Detailsview1.FindControl("Dept").Readonly but neither exist. Is it even
> possible to set the readonly property of a BoundField in the code-behind?
> --
> Regards,
>
> Mike D
> Coding in C# since Feb 2007
RE: Dynamic ReadOnly in DetailsView
am 15.01.2008 17:13:01 von MikeD
Thanks that helped!
--
Regards,
Mike D
Coding in C# since Feb 2007
"Angel" wrote:
> Yes Mike! I do that routinely... But it also depends. I do not relie on any
> declarative stuff or Datasouce cotrols so I completely bound my control
> programmatically.
>
> In my column definition I do the following
>
> ' category id
> bf = New boundField
> bf.DataField="CategoryID"
> bf.HeaderText = "Category ID"
> bf.ReadOnly = True ' This could be of course done dynamically at this point
> detailsView1.Fields.add(bf)
>
> I tested this before answering you and it works.
>
> --
> aaa
>
>
> "Mike D" wrote:
>
> > I need to dynamically set the ReadOnly value in a BoundField in a
> > DetailsView. The DetailsView is generated from a GridView selection and has
> > both Edit and New buttons. I need to be able to set the readonly property on
> > one of the fields depending on the user's group. I have tried to access the
> > property by Detailsview1.Fields[3].Readonly and by
> > Detailsview1.FindControl("Dept").Readonly but neither exist. Is it even
> > possible to set the readonly property of a BoundField in the code-behind?
> > --
> > Regards,
> >
> > Mike D
> > Coding in C# since Feb 2007
RE: Dynamic ReadOnly in DetailsView
am 28.01.2008 21:39:01 von Geo
Why dont you try using a ItemTemplate inside a DetailsView. Then you can
access it and make it using FIND CONTROL and make it read only. Just sharing
an idea incase if the other method didnt work.
"Mike D" wrote:
> Thanks that helped!
> --
> Regards,
>
> Mike D
> Coding in C# since Feb 2007
>
>
> "Angel" wrote:
>
> > Yes Mike! I do that routinely... But it also depends. I do not relie on any
> > declarative stuff or Datasouce cotrols so I completely bound my control
> > programmatically.
> >
> > In my column definition I do the following
> >
> > ' category id
> > bf = New boundField
> > bf.DataField="CategoryID"
> > bf.HeaderText = "Category ID"
> > bf.ReadOnly = True ' This could be of course done dynamically at this point
> > detailsView1.Fields.add(bf)
> >
> > I tested this before answering you and it works.
> >
> > --
> > aaa
> >
> >
> > "Mike D" wrote:
> >
> > > I need to dynamically set the ReadOnly value in a BoundField in a
> > > DetailsView. The DetailsView is generated from a GridView selection and has
> > > both Edit and New buttons. I need to be able to set the readonly property on
> > > one of the fields depending on the user's group. I have tried to access the
> > > property by Detailsview1.Fields[3].Readonly and by
> > > Detailsview1.FindControl("Dept").Readonly but neither exist. Is it even
> > > possible to set the readonly property of a BoundField in the code-behind?
> > > --
> > > Regards,
> > >
> > > Mike D
> > > Coding in C# since Feb 2007