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

ItemCommand event doesn't fire

3 Answers 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nicole
Top achievements
Rank 1
Nicole asked on 13 Sep 2011, 07:49 PM
I have a new RadGrid on a page within an existing asp Update Panel.  I have enabled selecting rows, and created an event to run when the user selects a row, and I thought I did what I needed to tell the RadGrid which event to fire, but I can't get the server side event to fire.  Can someone please tell me what am I missing here?

<telerik:RadGrid ID="gridLink" runat="server" AllowPaging="True" AutoGenerateColumns="False" CellSpacing="0" 
            DataSourceID="sdsLinkRecords" GridLines="None" ShowGroupPanel="True" AllowCustomPaging="True" Skin="Simple" 
            OnItemCommand="gridLink_ItemCommand">
            <ClientSettings AllowDragToGroup="True">
                <Selecting AllowRowSelect="True" />
            </ClientSettings>
            <MasterTableView DataKeyNames="fullID" DataSourceID="sdsLinkRecords">
                <CommandItemSettings ExportToPdfText="Export to PDF" />
                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                    <HeaderStyle Width="10px" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                    <HeaderStyle Width="10px" />
                </ExpandCollapseColumn>
                <Columns>
 ...
                </Columns>
                <EditFormSettings>
                    <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                    </EditColumn>
                </EditFormSettings>
            </MasterTableView>
            <FilterMenu EnableImageSprites="False">
            </FilterMenu>
            <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
            </HeaderContextMenu>
        </telerik:RadGrid>

Protected Sub gridLink_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles gridLink.ItemCommand
  
        If e.CommandName = "Select" Then
            Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
            Dim oldReportsID As String = lblFullSeqNum.Text
            Dim tblIncidentsID As Integer = item("tblIncidentsID").Text
  
....
        End If
  
    End Sub

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Sep 2011, 06:40 AM
Hello Nicole,

When the ClientSettings.Selecting.AllowRowSelect property is True, it will select a Row with a Click (Client-side). In order to fire the server side event you need to try any of the approach mentioned in the following document.
Selecting a Row with a CheckBox (Server-side)
Selecting a Row with a Select Button (Server-side)

Thanks,
Princy.
0
Accepted
Sebastian
Telerik team
answered on 14 Sep 2011, 07:49 AM
Or set ClientSettings > EnablePostBackOnRowClick = true as it is done for the first and second grid on this demo:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectedvalue/defaultcs.aspx

Greetings,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Nicole
Top achievements
Rank 1
answered on 14 Sep 2011, 12:25 PM
Thank you, Sebastian, that's exactly what I needed.  I did not want to require my users to do multiple clicks such as with a select button.

For future reference, I also had to modify my code behind.  Instead of e.CommandName = "Select," I needed:
If e.CommandName = "RowClick" Then
Tags
Grid
Asked by
Nicole
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Sebastian
Telerik team
Nicole
Top achievements
Rank 1
Share this question
or