Set Enabled or Visible on gridview cell contols?

This is a discussion on Set Enabled or Visible on gridview cell contols? within the DOTNET forums in Framework and Interface Programming category; 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. ...

Go Back   Application Development Forum > Framework and Interface Programming > DOTNET

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-07-2008, 05:50 PM
Savvoulidis Iordanis
Guest
 
Default 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?
Reply With Quote
  #2  
Old 09-07-2008, 05:57 PM
Savvoulidis Iordanis
Guest
 
Default RE: Set Enabled or Visible on gridview cell contols?

Also, how can I change the ReadOnly property of a field, when it's about to
enter the edit mode?
Reply With Quote
  #3  
Old 09-08-2008, 04:50 AM
Eliyahu Goldin
Guest
 
Default Re: Set Enabled or Visible on gridview cell contols?

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" <SavvoulidisIordanis@discussions.microsoft.com> wrote
in message news:45223B70-51F2-41B4-AD74-AC69CE5A942A@microsoft.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?



Reply With Quote
  #4  
Old 09-08-2008, 04:57 AM
Eliyahu Goldin
Guest
 
Default Re: Set Enabled or Visible on gridview cell contols?

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" <SavvoulidisIordanis@discussions.microsoft.com> wrote
in message news:C337A7EE-DBCD-4982-B5DF-C1694DB7DF46@microsoft.com...
> Also, how can I change the ReadOnly property of a field, when it's about
> to
> enter the edit mode?



Reply With Quote
  #5  
Old 09-09-2008, 02:30 AM
Savvoulidis Iordanis
Guest
 
Default Re: Set Enabled or Visible on gridview cell contols?

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
Reply With Quote
  #6  
Old 09-09-2008, 02:33 AM
Savvoulidis Iordanis
Guest
 
Default Re: Set Enabled or Visible on gridview cell contols?

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?
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 09:38 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.