473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Dynamic ReadOnly in DetailsView

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
Oct 29 '07 #1
3 5275
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
Jan 14 '08 #2
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
Jan 15 '08 #3
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
Jan 28 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Jim Hammond | last post by:
I am passing the whole object instead or parameters in my select and update methods. I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate an update button, and then press...
4
by: Frits van Soldt | last post by:
Hello, I hope somebody can help me with this! I have 2 listboxes in the edititemtemplate of a detailsview. In the databound event of the detailsview I would like to fill the listboxes...
1
by: GoogleAccounts | last post by:
I have a simple DetailsView in ReadOnly mode. I have paging enabled because I need to show more than one record. When user clicks next/prev page (PageIndexChanged event) I need to get the...
1
by: Jason | last post by:
Does anyone know if there is a way, natively, to create a dynamic number of DetailsView controls on a page based on a selection from a GridView? Basically, I have one-to-many relationship between...
4
by: scottcly | last post by:
I have a simple editor with a Gridview and a DetailsView. The Gridview handles DELETE and the DetailsView handles UPDATE and ADD. A panel around each one and some minor event handling is used to...
0
by: mtsylvester | last post by:
Hi All, How do I add a List Box to a dynamic Details View. I want to replace the check boxes with list boxes. If I try to simply replace the check box with a list box it complains about not being...
2
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, can someone please help me decide on which way to go. i get a single untyped data table which can contain different fields and values at different times. so i'm thinking i would...
2
by: makennedy | last post by:
Hi Experts, Please help, I am a newbie to ASP.NET 2.0 may be I am doing something wrong or there may be a bug somewhere. Basically I have a TreeView Control which I have created...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.