ButtonColumn in a DataGrid

J

jmclej

Hi,

I would like to use a buttoncolumn in my datagrid. But I don't want to
enable the click on it on all the rows. I want to enable the button
according to the data specified in another column. First of all is it
possible to do so, and if yes, how can it be done?
Thanks for your help.
JULIEN
 
G

Guest

Yes it can be done.

1) Handle the ItemDataBound event, 2) check for the condition, 3) locate the
button within the item handled by the event, 4) disable the button.

This sample http://www.societopia.net/samples/dataGrid_5c.aspx handles the
ItemDataBound, and changes the attributes of a buttonColumn of type
LinkButton.

To disable the button you can either replace it with a simple literal
control upon DataBinding or change its onClick event to alert the user (using
JavaScript) that no action is available for this selection.
 
T

Trevor Benedict R

Button1.Attributes.Add("OnClick", "JavaScript: return(false);") should also
disable the button. I did not check this code through.

Trevor Benedict R
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top