Set Enabled or Visible on gridview cell contols?

  • Thread starter Savvoulidis Iordanis
  • Start date
S

Savvoulidis Iordanis

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?
 
S

Savvoulidis Iordanis

Also, how can I change the ReadOnly property of a field, when it's about to
enter the edit mode?
 
E

Eliyahu Goldin

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
 
S

Savvoulidis Iordanis

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
 
S

Savvoulidis Iordanis

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top