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

Disabled RadButton inside of RadGrid using OnItemCommand

2 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Avihai
Top achievements
Rank 1
Avihai asked on 31 Mar 2014, 03:34 AM
 <telerik:RadGrid
         ID="rgOfficersToCallIn"
         runat="server"
         AutoGenerateColumns="False"
         AllowPaging="True"
         AllowSorting="True"
         PageSize="17"
         CellSpacing="0" GridLines="None"
         OnSortCommand="rgOfficersToCallIn_SortCommand"
         OnPageIndexChanged="rgOfficerToCallIn_PageIndexChanged"
         EnableHeaderContextFilterMenu="True" 
         Width="1200px"
         Height="640px">
            <ClientSettings EnablePostBackOnRowClick="true">              
                <Selecting AllowRowSelect="True" />
                <Scrolling AllowScroll="true" UseStaticHeaders="True" SaveScrollPosition="true" />
            </ClientSettings>
            <MasterTableView ShowHeadersWhenNoRecords="true" NoMasterRecordsText="No Employees Records to display" GridLines="None" ItemStyle-Height="23px" Font-Size="11px" TableLayout="Auto">
                <PagerStyle Mode="NumericPages" AlwaysVisible="true"></PagerStyle>
                <Columns>             
                    <telerik:GridBoundColumn HeaderText="HR EmployeeID" HeaderStyle-Width="120px" Display="false" DataField="HREmployeeID" FilterControlWidth="40px" ShowFilterIcon="false" SortExpression="HREmployeeID"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Employee Number" HeaderStyle-Width="100px" DataField="EmployeeNumber" FilterControlWidth="95px" ShowFilterIcon="false" SortExpression="EmployeeNumber"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="First Name" HeaderStyle-Width="70px" DataField="FirstName" FilterControlWidth="105px" ShowFilterIcon="false"  SortExpression="FirstName"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Last Name" HeaderStyle-Width="70px" DataField="LastName" FilterControlWidth="84px" ShowFilterIcon="false"  SortExpression="LastName"></telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="City" HeaderStyle-Width="90px" DataField="City" FilterControlWidth="78px" ShowFilterIcon="false" SortExpression="City"></telerik:GridBoundColumn>
                   <%-- <telerik:GridBoundColumn HeaderText="Guard Card Number" HeaderStyle-Width="110px" DataField="GuardCardNumber" FilterControlWidth="72px" ShowFilterIcon="false" SortExpression="GuardCardNumber"></telerik:GridBoundColumn>                    --%>
                    <telerik:GridDateTimeColumn  HeaderText="Guard Card Expired" HeaderStyle-Width="110px" DataField="GuardCardExpired" FilterControlWidth="63px" ShowFilterIcon="false"></telerik:GridDateTimeColumn>
                   <%-- <telerik:GridBoundColumn HeaderText="Fire Arm Number" HeaderStyle-Width="90px" DataField="FireArmNumber" FilterControlWidth="72px" ShowFilterIcon="false" SortExpression="FireArmNumber"></telerik:GridBoundColumn>                   
                    <telerik:GridDateTimeColumn  HeaderText="Fire Arm Expired" HeaderStyle-Width="90px" DataField="FireArmExpired" FilterControlWidth="63px" ShowFilterIcon="false"></telerik:GridDateTimeColumn>--%>
                    <telerik:GridTemplateColumn HeaderText="On Call" HeaderStyle-Width="80px" AllowFiltering="false" UniqueName="OnCallButton">
                    <ItemTemplate>
                      <telerik:RadButton ID="btnOnCall" runat="server" Text="On Call" CommandName="OnCall" >
                          <Icon PrimaryIconCssClass="rbAdd" PrimaryIconLeft="4" PrimaryIconTop="4"></Icon>
                      </telerik:RadButton>
                    </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>


**************************************************VB CODE****************************************
  Protected Sub rgOfficersToCallIn_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgOfficersToCallIn.ItemCommand
        Try
            lblMessage.Text = ""
            divMessage.Visible = False            Dim setDate As Date? = rdtpCallIn.SelectedDate.ToString()
            If setDate Is Nothing Then
                Return
            End If
            Dim cellEmployeeID As TableCell = e.Item.Cells(DirectCast(eOfficersCallInColumns.HREmployeeID, Int32))
            If e.CommandName.ToString() = "OnCall" Then
                Dim dba As New DBAccess
                If dba.InsertCallInOfficer(m_SessionID, Convert.ToInt32(cellEmployeeID.Text), setDate) Then
                    If e.Item.Selected = True Then
                        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
                        Dim btn As RadButton = DirectCast(item("OnCallButton").FindControl("btnOnCall"), RadButton)
                        btn.Enabled = False
                    End If
                    rgCallIn.Rebind()
                    upCallIn.Update()
                    divMessage.Visible = True
                    lblMessage.Text = "Officer is now on call for " + setDate
                Else
                    rgCallIn.DataSource = New String() {}
                    rgCallIn.DataBind()
                End If
            End If


        Catch ex As Exception
        End Try
    End Sub

2 Answers, 1 is accepted

Sort by
0
Avihai
Top achievements
Rank 1
answered on 31 Mar 2014, 03:41 AM
I don't know why I can't edit my post..... This my RadGrid and I have RadButton inside of it (for each row in the Grid there is a button)
I want when the user click on the button for the row that he was selected the button will be disabled.

In my function its doing it only one time and not for the other rows that the user selected
how can I disabled the button for each click of the button for a different row?

Thanks
0
Avihai
Top achievements
Rank 1
answered on 31 Mar 2014, 03:41 AM
I don't know why I can't edit my post..... This my RadGrid and I have RadButton inside of it (for each row in the Grid there is a button)
I want when the user click on the button for the row that he was selected the button will be disabled.

In my function its doing it only one time and not for the other rows that the user selected
how can I disabled the button for each click of the button for a different row?

Thanks
Tags
Grid
Asked by
Avihai
Top achievements
Rank 1
Answers by
Avihai
Top achievements
Rank 1
Share this question
or