Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dynamic ReadOnly in DetailsView

Reply
Thread Tools

Dynamic ReadOnly in DetailsView

 
 
=?Utf-8?B?TWlrZSBE?=
Guest
Posts: n/a
 
      10-29-2007
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
 
Reply With Quote
 
 
 
 
Angel
Guest
Posts: n/a
 
      01-14-2008
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

 
Reply With Quote
 
 
 
 
Mike D
Guest
Posts: n/a
 
      01-15-2008
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

 
Reply With Quote
 
Geo
Guest
Posts: n/a
 
      01-28-2008
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

 
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
Selectively set readonly for detailsview fields gerry ASP .Net 3 09-26-2007 06:21 AM
Can't get current record ID from DetailsView (ReadOnly) GoogleAccounts@salutony.com ASP .Net 1 04-02-2006 11:29 AM
DetailsView - Changing to Insert Mode (Not By Using the Insert Button In the DetailsView Control) Feege ASP .Net Web Controls 0 12-20-2005 12:28 AM
dynamic readOnly for type=text works, but not for checkbox Randell D. Javascript 5 03-15-2005 12:25 AM
ASP.NET Readonly panel function with readonly checkbox, readonly radiobutton Jonathan Hyatt ASP .Net Web Controls 1 06-08-2004 07:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57