473,888 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Fi elds[3].Readonly and by
Detailsview1.Fi ndControl("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 5296
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
programmaticall y.

In my column definition I do the following

' category id
bf = New boundField
bf.DataField="C ategoryID"
bf.HeaderText = "Category ID"
bf.ReadOnly = True ' This could be of course done dynamically at this point
detailsView1.Fi elds.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.Fi elds[3].Readonly and by
Detailsview1.Fi ndControl("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
programmaticall y.

In my column definition I do the following

' category id
bf = New boundField
bf.DataField="C ategoryID"
bf.HeaderText = "Category ID"
bf.ReadOnly = True ' This could be of course done dynamically at this point
detailsView1.Fi elds.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.Fi elds[3].Readonly and by
Detailsview1.Fi ndControl("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
programmaticall y.

In my column definition I do the following

' category id
bf = New boundField
bf.DataField="C ategoryID"
bf.HeaderText = "Category ID"
bf.ReadOnly = True ' This could be of course done dynamically at this point
detailsView1.Fi elds.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.Fi elds[3].Readonly and by
Detailsview1.Fi ndControl("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
8714
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 update after making changes, but I don't want that update button. How can I get the updated object when the user presses one of my other action buttons?
4
16079
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 programmatically (not through databinding). If I use detailsview.findcontrol(controlname) then an empty object is returned. How can I address these controls? Thank you for your time.
1
2172
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 current record ID (that is not one of the displayed fields, so ..Cell(x) won't work). I expected DetailsView.SelectedValue to do the job but it doesn't (it's always Nothing).
1
2528
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 two tables and I want to show all of the entires from the second table based on the selection from the first table out of a DataGrid. I have this working just fine with a one-to-one relationship. I'm trying to avoid dynamically creating them...
4
5150
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 control which one is visible based on buttons pushed. I can do single operations, but I get an error when I click SELECT on the GRIDVIEW, then UPDATE on the DetailsView then SELECT on the Gridview again. I will have to send the code in a follow-on...
0
1427
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 able to convert it to a datacontrol field. Below is a portion of my current code behind. By the way I tried doing dynamic templates and was not able to get it to work. Please help, this is driving me nuts. Thanks
2
1875
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 dynamically generate the html table which would take care of displaying the data. but would it be better or the same to use a formview or detailsview dynamically? thanks,
2
5517
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 programmatically. And I want to bind the selection of a TreeNode (which is a record) from the database) to a DetailsView which shows the datatable record for the selected TreeView node in the Details View. I am using IDE : Visual Web Developer 2005 Express; OS=...
5
3473
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: default.aspx:
0
9961
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9800
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10778
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7990
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7148
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4247
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3252
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.