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

set a button visible after click to a telerik:GridButtonColumn

3 Answers 243 Views
Grid
This is a migrated thread and some comments may be shown as answers.
fatma
Top achievements
Rank 1
fatma asked on 16 Apr 2014, 04:33 PM
Hello,
I have a RadGridwhich contains a GridButtonColumn named "Update" and a button under the RadGrid wich is invisible.
I want to set the button visible after click to the GridButtonColumn "Update".

code Asp:

<div id="lprulesdetails-container">
      <telerik:RadGrid ID="RadGridLPRulesDetails" runat="server" AllowPaging="True" AllowFilteringByColumn="true"
            AllowAutomaticDeletes="true" AllowAutomaticUpdates="true" PageSize="5">
            <MasterTableView AutoGenerateColumns="false">
                <Columns>
                    ...................
                    <telerik:GridButtonColumn ButtonType="LinkButton" CommandName="Update" 
                        Text="Update" UniqueName="Update" ItemStyle-Width="100px">
                    </telerik:GridButtonColumn>
                </Columns>
            </MasterTableView>
            <PagerStyle Mode="NumericPages"></PagerStyle>
        </telerik:RadGrid>
<div id="lprulescontainer">
        <div id="lprulesaddcontainer" runat="server">
            <div id="grid-action">
                <div class="action-operation-left">
                    <telerik:RadButton ID="RadButtonCancelAdding" runat="server" Text="Cancel" Visible="false">
                        <Icon PrimaryIconCssClass="rbCancel" PrimaryIconLeft="4" PrimaryIconTop="4" />
                    </telerik:RadButton>
                </div>
          ........................
</div>

Code VB.net

Private Sub RadGridLPRulesDetails_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridLPRulesDetails.ItemCommand
       If e.CommandName = "Update" Then
            RadButtonCancelAdding.Visible = True
        End If
    End Sub


Where is the matter?

Thanks :)

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Apr 2014, 03:59 AM
Hi Fatma,

When using the CommandName="Update", the RadGrid.UpdateCommand event fires. In your case you are using it in a GridButtonColumn, and the grid is not in edit mode to fire this event and it will cause error. You can use any other commandname for the button. Please check the following code snippet. If this is not the requirement please elaborate on it.

ASPX:
<telerik:GridButtonColumn ButtonType="LinkButton" CommandName="UpdateRow" Text="Update" UniqueName="UpdateRow" >
</telerik:GridButtonColumn>

VB:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As GridCommandEventArgs)
    If e.CommandName = "UpdateRow" Then
        RadButtonCancelAdding.Visible = True
    End If
End Sub

Thanks,
Princy
0
fatma
Top achievements
Rank 1
answered on 17 Apr 2014, 09:19 AM
Thanks Princy for your response,

I tried this but it doesn't work.
I think the problem is that the radgrid and the button are not in the same div.
Did you think so?
0
Princy
Top achievements
Rank 2
answered on 21 Apr 2014, 06:03 AM
Hi Fatma,

There is no such issue as the Grid and the button lies in different div. Unfortunately I was unable to replicate the issue. Below is a sample code that i tried.

ASPX:
<div id="mainGrid">
    <telerik:RadGrid ID="RadGridSample" runat="server" AutoGenerateColumns="false" AllowPaging="true"DataSourceID="SqlDataSource1">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity">
                </telerik:GridBoundColumn>
                <telerik:GridButtonColumn ButtonType="LinkButton" CommandName="UpdateRow" Text="UpdateRow"UniqueName="UpdateRow">
                </telerik:GridButtonColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
</div>
<div>
    <div class="cancelBtnDiv">
        <telerik:RadButton ID="RadBtnCancel" runat="server" Text="Cancel" Visible="false">
        </telerik:RadButton>
    </div>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
    SelectCommand="SELECT  * FROM [Orders]"></asp:SqlDataSource>

VB:
Protected Sub RadGrid1_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
        If e.CommandName = "UpdateRow" Then
            RadBtnCancel.Visible = True
        End If
End Sub

Thanks,
Princy
Tags
Grid
Asked by
fatma
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
fatma
Top achievements
Rank 1
Share this question
or