473,397 Members | 2,077 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,397 software developers and data experts.

Set Enabled or Visible on gridview cell contols?

Can I set the Enabled or Visible properties of the controls (textboxes,
checkboxes) displayed by default in edit mode, depending on the value of some
other column? Or must I convert the column to a template column first? What I
mean is, I can correctly get the value of the default textbox in a gridview
cell when edited, using:

s = CType(grd_users.Rows(index).Cells(4).Controls(0), TextBox).Text

but I can't set that textbox to disabled or hidden using

CType(grd_users.Rows(index).Cells(4).Controls(0), TextBox).enabled=false or
CType(grd_users.Rows(index).Cells(4).Controls(0), TextBox).visible=false

although I have intellisence for them.
The message I get is:
"Specified argument was out of the range of valid values. Parameter name:
index"

Why?
Sep 7 '08 #1
5 3807
Also, how can I change the ReadOnly property of a field, when it's about to
enter the edit mode?
Sep 7 '08 #2
You must've been looking in different places.

In the same place, if you don't get an exception because of index in
s = CType(grd_users.Rows(index).Cells(4).Controls(0), TextBox).Text

you can't get it in
CType(grd_users.Rows(index).Cells(4).Controls(0), TextBox).enabled=false

since index is used before you get to Enabled property.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Savvoulidis Iordanis" <Sa*****************@discussions.microsoft.comwrot e
in message news:45**********************************@microsof t.com...
Can I set the Enabled or Visible properties of the controls (textboxes,
checkboxes) displayed by default in edit mode, depending on the value of
some
other column? Or must I convert the column to a template column first?
What I
mean is, I can correctly get the value of the default textbox in a
gridview
cell when edited, using:

s = CType(grd_users.Rows(index).Cells(4).Controls(0), TextBox).Text

but I can't set that textbox to disabled or hidden using

CType(grd_users.Rows(index).Cells(4).Controls(0), TextBox).enabled=false
or
CType(grd_users.Rows(index).Cells(4).Controls(0), TextBox).visible=false

although I have intellisence for them.
The message I get is:
"Specified argument was out of the range of valid values. Parameter name:
index"

Why?

Sep 8 '08 #3
RowEditing event should be good for this.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Savvoulidis Iordanis" <Sa*****************@discussions.microsoft.comwrot e
in message news:C3**********************************@microsof t.com...
Also, how can I change the ReadOnly property of a field, when it's about
to
enter the edit mode?

Sep 8 '08 #4
What I need is a code excerpt. I couldn't manage to write it properly. I
can't event get correct object reference to have intellisence for .Readonly
Sep 9 '08 #5
Boh the following statements are used in RowCommand event. The 2nd one gives
the exception

s = CType(grd_users.Rows(index).Cells(4).Controls(0), TextBox).Text

CType(grd_users.Rows(index).Cells(4).Controls(0), TextBox).enabled=false

Why?
Sep 9 '08 #6

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

Similar topics

2
by: Chris Davoli | last post by:
How do you enable a check box in the GridView. I selected Checkbox Field in the Columns of the GridView, and the check box shows up in the Grid view, but it is disabled. How do I enable it so I can...
7
by: aljamala | last post by:
Hi, I was wondering if there is a way to make a single cell readonly within a GridView? I know you can do it for a column but what about a cell within that column? Thanks!
1
by: jobs | last post by:
Can somebody tell me why Jobno and Value BoundFields are not available during the command SaveParm ? i enter text into the box for Value and hit the Save button, but all I see is the Parmvalue. ...
3
by: Bill Gower | last post by:
I have an cell which contains a field member which is filled with String.Empty. When I retrieve the value in the cell with Cells.Text.ToString() and try to compare it to String.Empty, I can't...
3
by: jc | last post by:
Hello. I have a gridview column item that i want to not make visible if the bound data in that cell is less than a value in a textbox. However, I notice at the time my code checks a function...
0
by: mattd1 | last post by:
I'm using VS2008, and I need to put a gridview into a table cell (an asp table). I made the gridview and set it all up outside the table, then I edit the HTML and move the gridview into the table...
1
Frinavale
by: Frinavale | last post by:
I'm working on an ASP.NET application using VB.NET for server side code. I have a GridView listing a bunch of stuff. Above the GridView I have a checkbox named "ChkBx_SelectAll". If this...
4
by: foolmelon | last post by:
Before AJAX, we were able to focus a cell in a gridview during a fullpage postback. After putting the gridview inside an UpdatePanel, we cannot focus a cell in this gridview anymore. Does anybody...
9
by: ally | last post by:
Hi, I am programmatically binding gridview to a datatable. I want to hide 2 columns. I can be done by adding code in RowCreated event of gridview like e.Row.Cells.Visible = false; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.