Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ButtonColumn in a DataGrid

Reply
Thread Tools

ButtonColumn in a DataGrid

 
 
jmclej@hotmail.com
Guest
Posts: n/a
 
      10-11-2005
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

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      10-11-2005
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.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"(E-Mail Removed)" wrote:

> 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
>
>

 
Reply With Quote
 
 
 
 
Trevor Benedict R
Guest
Posts: n/a
 
      10-12-2005
Button1.Attributes.Add("OnClick", "JavaScript: return(false);") should also
disable the button. I did not check this code through.

Trevor Benedict R

"Phillip Williams" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "(E-Mail Removed)" wrote:
>
>> 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
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why <asp:ButtonColumn> for datagrid doesn't have CausesValidation property like <asp:Button> z. f. ASP .Net 4 06-23-2004 07:26 AM
Confirming Delete for a asp:ButtonColumn in asp:datagrid.. RSB ASP .Net 6 05-19-2004 04:27 PM
DataGrid ButtonColumn/BoundColumn problem John ASP .Net 3 11-03-2003 02:20 PM
Enabling/Disabling a DataGrid ButtonColumn CGuy ASP .Net 2 10-22-2003 05:43 PM
How to use ButtonColumn to select a Datagrid row? Northern ASP .Net 0 07-22-2003 08:34 PM



Advertisments