How to disable a GridView delete button depending on a value in the datasource?

K

keithb

I have a GridView control that has a delete button (hyperlink) in one
column. The datasource table contains a column that has a true/false
indicator showing whether or not the record can be deleted. How can I
enable/disable the delete button depending on the value of the indicator?
Ideally, I would like to make the button invisible where a record cannot be
deleted.

Thanks,

Keith
 
C

Craig Deelsnyder

keithb said:
I have a GridView control that has a delete button (hyperlink) in one
column. The datasource table contains a column that has a true/false
indicator showing whether or not the record can be deleted. How can I
enable/disable the delete button depending on the value of the indicator?
Ideally, I would like to make the button invisible where a record cannot be
deleted.

Thanks,

Keith

You will pry have to create your own TemplateColumn that will hold a
delete button (add it to the template(s)). Set its CommandName="Delete"
and it will replace the one 'built into' the GridView just fine (also
disable Deleting in the GridView's properties, otherwise the default one
will also show up).

Once you have a button, you can bind its Visible property to the value
of the indicator.
 

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

Top