How can I disable a Delete button Based on Condition

How can I disable a Delete button Based on Condition

Post by Paul D. Fo » Sat, 11 Jun 2005 23:37:52


I have a Datagrid displaying "Start Date" and "End Date" with a Delete
Button. I want to disable the Delete Button if the Start Date is less than
current date. I believe you do this in the "DataGrid1_ItemDataBound" but
not sure what to code here.

Paul
 
 
 

How can I disable a Delete button Based on Condition

Post by Brock Alle » Sun, 12 Jun 2005 03:03:47

In the ItemDataBound use FindControl("TheIDOfTheButton") to get access the
the Control. Once you have the control, you can set the Enabled property.
You'll have to call FindControl on the DataGridItemEventArgs.Item, which
is the row in the DataGrid that was just DataBound.

-Brock
DevelopMentor
http://www.yqcomputer.com/

 
 
 

How can I disable a Delete button Based on Condition

Post by Sm9ob » Thu, 16 Jun 2005 03:09:04

Hey I'm having a similar problem. I need to deactivate a control on my
datagrid based on the results of an sql query. i cant figure out a a good
place or way to loop through the results of the query and disable the
control. there are 3 kinds of PINs bieng boudn to the data grid.
Deactivated Masters, Deactivated sub pins with active masters and deactivated
subs without active masters. i need to be able to look through the lists of
pins and determine what catagory they fall into(i have a sql statement for
this) and if i find an deactivated sub with a deactivated master i want to
disable the activate button so we dont activate a pin that we cant see or
use(beacuse the managemnt grid is controlled by master pins). any help
would be appreciated. the only place i can think of is to use an
OnItemDataBound method but that seems like it could take awhile and i'm not
sure how to step through the information in my SqlDataReader to test for my
cases