This is a migrated thread and some comments may be shown as answers.

Disable/Enable Button in GridTemplateColumn on client side OnRowSelected/OnRowDeselected

3 Answers 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
B
Top achievements
Rank 1
B asked on 07 Aug 2008, 05:49 PM
Can someone tell me how to disable/enable a button that was created inside a GridTemplateColumn in the client-side OnRowSelected/OnRowDeselected events.

Basically when a row is selected, I want its button to be enabled and all other rows buttons to be disabled.

Thanks,
Blake

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Aug 2008, 05:26 AM
Hi B,

You can refer the following code library submission which explains how to access controls in a GridTemplateColumn on the client side.
Accessing server controls in a grid template on the client

Thanks
Shinu.
0
B
Top achievements
Rank 1
answered on 08 Aug 2008, 04:22 PM
I was able to figure out how using the article you linked me to, but now I have run into another problem. If the asp button in the TemplateColumn in my RadGrid is disabled at the start, the ItemCommand event fails to fire for the button click. How can I fix this? I need the button to start disabled, then when the row is clicked the button is enabled, and then when the button is clicked the ItemCommand event fires for the grid.

Thanks,
Blake

<telerik:GridTemplateColumn UniqueName="confirmDealTemplateColumn">
   
<ItemTemplate>
        <asp:Button ID="Button1" runat="server" Text="Button" CommandName="ConfirmDeal" Enabled="False" />
    </ItemTemplate>
</telerik:GridTemplateColumn>

0
Yavor
Telerik team
answered on 11 Aug 2008, 06:59 AM
Hello B,

This seems to be a limitation of the button itself, when dealing with the disabled/enabled status.
One possible approach would be to re-enable it from the server - making a postback/callback once you click on the row.
Another option is to assign a css class to the button, from the server, which would resemble a disabled style. Then, from the client, you can alter this css class.
Additionally, for as long as a button has the "disabled" class assigned, you can cancel out its click event(s). thus simulating the same behavior.
I hope these suggestions help.

Regards,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
B
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
B
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or