Set Enabled or Visible on gridview cell contols?

  • Thread starter Thread starter Savvoulidis Iordanis
  • Start date 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?
 
Also, how can I change the ReadOnly property of a field, when it's about to
enter the edit mode?
 
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
 
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
 
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?
 
Back
Top