Hi. I would like to enable/disable a button when a select a row in a RadGrid.
In my ItemCommand event I do:
button.Enabled = true
but when the button keeps disable. I am also add a RadAjaxManager and I declared a source control, the grid and target control, the button but it does not work...?
Is there something I left out ?
In my ItemCommand event I do:
button.Enabled = true
but when the button keeps disable. I am also add a RadAjaxManager and I declared a source control, the grid and target control, the button but it does not work...?
Is there something I left out ?
8 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 09 May 2008, 07:51 AM
Hi,
Try the following code snippet to enable a button on selecting a particular row.
ASPX:
CS:
Thanks
Shinu.
Try the following code snippet to enable a button on selecting a particular row.
ASPX:
| <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="RadGrid1_ItemCommand" > |
| <ClientSettings > |
| <Selecting AllowRowSelect="true" /> |
| </ClientSettings> |
| <MasterTableView > |
| <Columns> |
| <telerik:GridButtonColumn UniqueName="SelectCol" ButtonType="LinkButton" Text="Select" HeaderText="Select" CommandName="Select" ></telerik:GridButtonColumn> |
| <telerik:GridTemplateColumn UniqueName="ButtonCol" HeaderText="ButtonCol" > |
| <ItemTemplate> |
| <asp:Button ID="Button1" runat="server" Enabled="false" Text="Button" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
CS:
| protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName == "Select") |
| { |
| GridDataItem item = (GridDataItem)e.Item; |
| Button btn = (Button)item["ButtonCol"].FindControl("Button1"); |
| btn.Enabled = true; |
| } |
| } |
Thanks
Shinu.
0
Yamil
Top achievements
Rank 1
answered on 09 May 2008, 01:42 PM
Thanks, Shinu
but the button is outside the grid...
but the button is outside the grid...
0
Princy
Top achievements
Rank 2
answered on 12 May 2008, 06:55 AM
0
Shinu
Top achievements
Rank 2
answered on 12 May 2008, 07:02 AM
Hi Yamil,
Try the following code snippet to achieve the desired scenario.
CS:
ASPX:
Hope this helps..
Shinu.
Try the following code snippet to achieve the desired scenario.
CS:
| protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName == "Select") |
| { |
| Button1.Enabled =true; |
| } |
| } |
ASPX:
| <telerik:RadGrid ID="RadGrid1" OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender" > |
| <ClientSettings EnablePostBackOnRowClick="true" > |
| <ClientEvents /> |
| <Selecting AllowRowSelect="true" /> |
| </ClientSettings> |
| <MasterTableView DataSourceID="SqlDataSource1"> |
| <Columns> |
| <telerik:GridButtonColumn UniqueName="Select" Text="Enable" CommandName="Select" ></telerik:GridButtonColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| <asp:Button ID="Button1" runat="server" Enabled="false" Text="Button" /> |
Hope this helps..
Shinu.
0
Yamil
Top achievements
Rank 1
answered on 13 May 2008, 12:05 AM
Thanks a lot Shinu and Princy...!
0
Shinu
Top achievements
Rank 2
answered on 13 May 2008, 05:00 AM
Hi Yamil,
If you need to ajaxify the entire scenario you can wrap the RadGrid and the Button inside a RadAjaxPanel and the use the above given code.
AJAX Panel
Shinu.
If you need to ajaxify the entire scenario you can wrap the RadGrid and the Button inside a RadAjaxPanel and the use the above given code.
AJAX Panel
Shinu.
0
Yamil
Top achievements
Rank 1
answered on 14 May 2008, 01:38 AM
Thanks again, Shinu...!
0
Yamil
Top achievements
Rank 1
answered on 14 May 2008, 01:38 AM
Thanks again, Princy...!