Get the datakey of the selected row OutOfRangeException

5 posts, 1 answers
  1. Herve
    Herve avatar
    39 posts
    Member since:
    Jun 2008

    Posted 03 Oct 2013 Link to this post

    Hi,

    I have an issue with the datakey that I'm trying to get from my code behind in the SelectedIndexChanged event (I want to update a panel above the Radgrid when a row is selected).

    I saw in the documentation that you recommend to use the following in SelectedIndexChanged 

    Dim MyId As Integer = (DirectCast(RadGrid1.SelectedItems(0), GridDataItem)).GetDataKeyValue("MessageId").ToString()


    My probleme is that I get the following error:

    System.ArgumentOutOfRangeException was unhandled by user code<br>  HResult=-2146233086<br>  Message=L'index était hors limites. Il ne doit pas être négatif et doit être inférieur à la taille de la collection.<br>Nom du paramètre : index<br>  ParamName=index<br>  Source=mscorlib<br>  StackTrace:<br>       à System.Collections.ArrayList.get_Item(Int32 index)<br>       à Telerik.Web.UI.GridItemCollection.get_Item(Int32 index)<br>       à messages_messages.RadGrid1_SelectedIndexChanged(Object sender, EventArgs e) dans E:\Visual Studio 2012\WebSites\Hotlinexxx\messages\messages.aspx.vb:ligne 34<br>       à System.EventHandler.Invoke(Object sender, EventArgs e)<br>       à Telerik.Web.UI.GridBaseDataList.OnSelectedIndexChanged(EventArgs e)<br>       à Telerik.Web.UI.RadGrid.RaisePostDataChangedEvent()<br>       à Telerik.Web.UI.RadCompositeDataBoundControl.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()<br>       à System.Web.UI.Page.RaiseChangedEvents()<br>       à System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)<br>  InnerException: 

    My Ragrid is inpired from the Outlook grid:
    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/webmail/defaultvb.aspx

    and in my opinion most important resizing in radsplitter:
    http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandsplitterresizing/defaultvb.aspx?product=grid
    regarding to the ajax it contains.

    Here is the ajax manager I use:

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxSettingCreated="RadAjaxManager1_AjaxSettingCreated"<br>        OnAjaxRequest="RadAjaxManager1_AjaxRequest"><br>        <AjaxSettings><br>            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"><br>                <UpdatedControls><br>                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl><br>                </UpdatedControls><br>            </telerik:AjaxSetting><br>            <telerik:AjaxSetting AjaxControlID="RadGrid1"><br>                <UpdatedControls><br>                    <telerik:AjaxUpdatedControl ControlID="LitMessage"></telerik:AjaxUpdatedControl><br>                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"  LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>   <br>                </UpdatedControls><br>            </telerik:AjaxSetting><br>        </AjaxSettings><br>    </telerik:RadAjaxManager>

    I have noticed that if I invert AjaxUpdatedControl ControlID="LitMessage" and ControlID="RadGrid1" the height of the grid is less of 100px height.

    Also resizing in rad splitter seems to be a problem for groupong the colomns but this his another story.

    I thank you in advance for you help.
    Best regards


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 04 Oct 2013 Link to this post

    Hi Herve,

    Please try the sample code snippet,I was able to get the Selected row DatakeyValue. If this doesn't help,please provide your full code snippet.

    ASPX:
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <style type="text/css">
      
        html
        {
                overflow:auto;
        } 
        html,
        body, 
        #<%= RadGrid1PanelClientID %>
        {
                margin:0;
                height:100%;
        }
      
        .p{margin:0;padding:20px;font:12px/1.8 verdana,sans-serif}
      
    </style>
    </telerik:RadCodeBlock>
    <script type="text/javascript">
        function ClientResized(sender, eventArgs) {
            $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest('ChangePageSize');
        }
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxSettingCreated="RadAjaxManager1_AjaxSettingCreated"
        OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadSplitter ID="RadSplitter1" Width="700px" runat="server" Orientation="Horizontal">
        <telerik:RadPane ID="gridPane" runat="server" Height="307px" OnClientResized="ClientResized"
            Scrolling="None">
            <telerik:RadGrid AllowPaging="true" PageSize="40" Width="100%" Height="100%" Style="border: 0;
                outline: none" ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false"
                OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged1">
                <MasterTableView AllowPaging="true" TableLayout="Fixed" DataKeyNames="OrderID">
                    <GroupByExpressions>
                        <telerik:GridGroupByExpression>
                            <SelectFields>
                                <telerik:GridGroupByField FieldName="ShipCity" HeaderText="ShipCity" />
                            </SelectFields>
                            <GroupByFields>
                                <telerik:GridGroupByField FieldName="ShipCity" SortOrder="Descending" />
                            </GroupByFields>
                        </telerik:GridGroupByExpression>
                    </GroupByExpressions>
                    <Columns>
                        <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" />
                        <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" />
                    </Columns>
                </MasterTableView>
                        
                <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                    <Selecting AllowRowSelect="true"></Selecting>
                    <Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>
                </ClientSettings>
            </telerik:RadGrid>
        </telerik:RadPane>
        <telerik:RadSplitBar CollapseMode="Both" ID="RadSplitBar2" runat="server" EnableResize="True">
        </telerik:RadSplitBar>
        <telerik:RadPane ID="listBoxPane" runat="server" CssClass="TextStyle" BackColor="#d9eeff"
            ForeColor="Black">
            <div style="padding: 10px 10px 10px 10px; margin: 10px 10px 10px 10px;">
                RadSplitter for ASP.NET AJAX
            </div>
        </telerik:RadPane>
    </telerik:RadSplitter>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Northwind_newConnectionString3 %>"
        SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource>

    VB:
    Protected Sub Page_Load(sender As Object, e As EventArgs)
        If Not Page.IsPostBack Then
            'Set initial value of the PageSize property.
            RadGrid1.PageSize = 10
        End If
    End Sub
    Protected Sub RadAjaxManager1_AjaxRequest(sender As Object, e As Telerik.Web.UI.AjaxRequestEventArgs)
        Select Case e.Argument.ToString()
            Case "ChangePageSize"
                'Calculate the number of rows that fit in the RadPane.
                'In this case 23 is the sum of the height of a single row and its upper border width.
                'Depending on the paticular scenario this value may vary.
                Dim rows As Integer = (Int32.Parse(Me.gridPane.Height.Value.ToString()) - 60) / 23
                If rows >= 1 Then
                    RadGrid1.PageSize = rows
     
                    ' Check whether the CurrentPageIndex is correct.
                    If Session("itemsCount") IsNot Nothing Then
                        Dim itemsCount As Integer = CInt(Session("itemsCount"))
                        Dim pageCount As Integer = CInt(Math.Ceiling((CDbl(itemsCount) / rows)))
                        If RadGrid1.MasterTableView.CurrentPageIndex > pageCount - 1 Then
                            RadGrid1.MasterTableView.CurrentPageIndex = pageCount - 1
                        End If
                    End If
     
                    RadGrid1.Rebind()
                End If
                Exit Select
        End Select
    End Sub
     
    Public RadGrid1PanelClientID As String
     
    Protected Sub RadAjaxManager1_AjaxSettingCreated(sender As Object, e As AjaxSettingCreatedEventArgs)
        If e.Initiator.ID = "RadGrid1" Then
            Me.RadGrid1PanelClientID = e.UpdatePanel.ClientID
        End If
    End Sub
     
    Protected Sub RadGrid1_SelectedIndexChanged1(sender As Object, e As EventArgs)
        Dim MyId As String = DirectCast(RadGrid1.SelectedItems(0), GridDataItem).GetDataKeyValue("OrderID").ToString()
    End Sub

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Herve
    Herve avatar
    39 posts
    Member since:
    Jun 2008

    Posted 04 Oct 2013 Link to this post

    Hi Princy and thanks for your support,

    Unfortunately, these changes didn't fix the problem and I'm alays getting this same error, here is the full code of my page :

    <%@ Page Title="" Language="VB" MasterPageFile="~/components/Hotlinexxx.master" AutoEventWireup="false" CodeFile="messages.aspx.vb" Inherits="messages_messages" %><br><%@ Register Src="~/components/MemberDetails.ascx" TagPrefix="uc1" TagName="MemberDetails" %><br><br><br><br><asp:Content ID="Content1" ContentPlaceHolderID="CphHead" Runat="Server"><br><br><telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"><br><br><style type="text/css"><br> <br>            html<br>            {<br>                 overflow:auto;<br>            }<br> <br>            html,<br>            body,<br> <br>            #<%= RadGrid1PanelClientID %><br>            {<br>                 margin:0;<br>                 height:100%;<br>            }<br> <br>            .p{margin:0;padding:20px;font:12px/1.8 verdana,sans-serif}<br> <br>        </style><br><br><script type="text/javascript"><br>    function ClientResized(sender, eventArgs) {<br>        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest('ChangePageSize');<br>    }<br><br>    function RowClick(sender, eventArgs) {<br>        <br>    }    <br></script><br><br> </telerik:RadCodeBlock><br><br></asp:Content><br><br><br><asp:Content ID="Content2" ContentPlaceHolderID="CphContent" Runat="Server"><br><br><br><telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxSettingCreated="RadAjaxManager1_AjaxSettingCreated"<br>    OnAjaxRequest="RadAjaxManager1_AjaxRequest"><br>    <AjaxSettings><br>        <telerik:AjaxSetting AjaxControlID="RadAjaxManager1"><br>            <UpdatedControls><br>                <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl><br>            </UpdatedControls><br>        </telerik:AjaxSetting><br>        <telerik:AjaxSetting AjaxControlID="RadGrid1"><br>            <UpdatedControls><br>                <telerik:AjaxUpdatedControl ControlID="LitMessage"></telerik:AjaxUpdatedControl><br>                <telerik:AjaxUpdatedControl ControlID="RadGrid1"  LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>   <br>            </UpdatedControls><br>        </telerik:AjaxSetting><br>    </AjaxSettings><br></telerik:RadAjaxManager><br><br><telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" MinDisplayTime="500" runat="server" /><br><telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" MinDisplayTime="500" runat="server" /><br><br><h1><asp:Literal ID="LitTitle" Text="<%$ Resources:Messages, MessTitle %>" runat="server" /></h1><br><br><br><br><telerik:RadSplitter ID="Radsplitter" Height="100%" Width="520px" Orientation="Horizontal" runat="server"><br><br><!-- Top Pane --><br> <telerik:RadPane ID="Rp1" runat="server" Width="100%" Height="300"><br><br>     <br><asp:Literal ID="LitMessage" runat="server" /><br><br><br><!-- End of Top Pane --><br> </telerik:RadPane><br><br><br><br><telerik:RadSplitBar ID="Rsb1" CollapseMode="Forward" runat="server"></telerik:RadSplitBar><br><br><br><br><br><telerik:RadPane ID="Rp2" Width="490" Height="500" OnClientResized="ClientResized" Scrolling="None" runat="server"><br><!-- Bottom Pane --><br><br><br><telerik:RadGrid ID="RadGrid1" runat="server"  Width="100%" Height="100%" Culture="fr-FR"  EnableEmbeddedSkins="False" Skin="Hotlinexxx"<br>GridLines="None" AutoGenerateColumns="False" Style="border: 0; outline: none;"  AllowMultiRowSelection="false"<br>AllowSorting="True" AllowPaging="True" CellSpacing="0" OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged" OnDeleteCommand="RadGrid1_DeleteCommand"<br>OnClientResized="ClientResized" Scrolling="None"><br><br><PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle><br><br><AlternatingItemStyle BackColor="#1e1e1e" /><br><SelectedItemStyle BorderStyle="Dashed" BorderWidth="1px" /><br><br>  <br><ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true"><br>        <Selecting AllowRowSelect="True" /><br>        <ClientEvents OnRowClick="RowClick" /><br>        <Scrolling AllowScroll="True" UseStaticHeaders="True"  SaveScrollPosition="True" /><br> </ClientSettings><br><br><MasterTableView DataKeyNames="MessageId" ClientDataKeyNames="MessageId"><br>      <br><br>    <Columns><br><br>    <br>        <telerik:GridBoundColumn DataField="MessageId" DataType="System.Int32" Display="False" FilterControlAltText="Filter MessageId column" HeaderText="MessageId" UniqueName="MessageId"><br>        </telerik:GridBoundColumn><br><br>      <br>        <telerik:GridDateTimeColumn DataField="SendingDate" FilterControlAltText="Filtrer par dates" HeaderText="Date" <br>        UniqueName="SendingDate"  DataFormatString="{0:d}"  Groupable="True" GroupByExpression="GrouperDates"><br>        <HeaderStyle Width="70px"></HeaderStyle><br>        </telerik:GridDateTimeColumn><br><br><br><br>        <telerik:GridTemplateColumn UniqueName="IsRead" HeaderText="v^" SortExpression="IsRead" Groupable="True"><br>            <HeaderStyle Width="30px"></HeaderStyle><br>            <ItemStyle HorizontalAlign="Center" Height="35px"></ItemStyle><br>            <ItemTemplate><br>                <img src='<%# IIf(Eval("IsRead") = 0, "/images/messages/unread.png", "/images/messages/read.png")%>' /><br>            </ItemTemplate><br>        </telerik:GridTemplateColumn><br><br><br><br>        <telerik:GridTemplateColumn UniqueName="TemplateColumn2" GroupByExpression="Grouper par utilisateur"<br>            SortExpression="Username" HeaderText="Pseudo/Sujet"  Groupable="True"><br>            <ItemStyle Height="35px"></ItemStyle><br>            <ItemTemplate><br>                <b><%# StrConv(DataBinder.Eval(Container.DataItem, "Username"), VbStrConv.ProperCase)%></b><br><br>                <br /><br>                <div class="MailSubject"><br>                    <%# DataBinder.Eval(Container.DataItem, "Subject") %><br>                </div><br>            </ItemTemplate><br>        </telerik:GridTemplateColumn><br><br><br>        <telerik:GridTemplateColumn UniqueName="TemplateColumn3" HeaderText="v^" SortExpression="Flagged" Groupable="True"><br>            <HeaderStyle Width="25px"></HeaderStyle><br>            <ItemStyle Height="35px"></ItemStyle><br>            <ItemTemplate><br>                <asp:ImageButton ID="MailFlagImageButton" BorderWidth="0px" CommandName="ChangeFlag" commandargument='<%#Eval("Flagged")%>' <br>                    ImageUrl='<%# IIf(Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "Flagged")), "/images/messages/MailFlagRed.png", "/images/messages/MailFlag.png") %>'<br>                    AlternateText="Important" Style="cursor: pointer;" runat="server"></asp:ImageButton><br>            </ItemTemplate><br>        </telerik:GridTemplateColumn><br><br>        <telerik:GridButtonColumn ConfirmText="" ConfirmDialogType="Classic"<br>            ConfirmTitle="Delete" ButtonType="ImageButton" ImageUrl="/images/messages/delete.gif" CommandName="Delete" ConfirmDialogHeight="160px"<br>            ConfirmDialogWidth="250px"><br>            <HeaderStyle Width="25px"></HeaderStyle><br>        </telerik:GridButtonColumn><br><br>        </Columns> <br><br></MasterTableView><br><br><br> <br></telerik:RadGrid><br><br><br><br><!-- End of Bottom Pane --><br></telerik:RadPane><br><br></telerik:RadSplitter><br><br>    <br /><br><br><br><br></asp:Content><br><br><br><asp:Content ID="Content3" ContentPlaceHolderID="CphEop" Runat="Server"><br></asp:Content>

    And the code behind:

    Imports Telerik.Web.UI<br>Imports System.Data<br>Imports System<br>Imports System.Web.UI.WebControls<br>Imports System.Configuration<br><br>Partial Class messages_messages<br>    Inherits System.Web.UI.Page<br><br>    Dim MessagesClass As New MessagesClass<br><br>    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)<br><br>        If Not Page.IsPostBack Then<br><br>            'Set initial value of the PageSize property.<br>            RadGrid1.PageSize = 10<br><br>        End If<br><br>    End Sub<br><br><br>    Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource<br>        RadGrid1.DataSource = MessagesClass.GetMessages(Session("UserId"))<br>    End Sub<br><br><br>    Protected Sub RadGrid1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadGrid1.SelectedIndexChanged<br><br>        <br>        ' Dim MyId As Integer = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("MessageId").ToString()<br><br>        Dim MyId As Integer = DirectCast(RadGrid1.SelectedItems(0), GridDataItem).GetDataKeyValue("Message").ToString()<br><br><br>        Dim Data As MessagesClass.MessageProfile = MessagesClass.GetMessage(Session("UserId"), MyId)<br><br>        Dim Sb As New StringBuilder<br>        Sb.Append("<p>" & Data.Subject & "</p>")<br>        Sb.Append("<p>" & Data.Message.Replace(vbCrLf, "<br />") & "test" & "</p>")<br><br>        LitMessage.Text = Sb.ToString()<br><br>        MessagesClass.EditStatut(MyId, True)<br><br>        ' RadGrid1.Rebind()<br><br>    End Sub<br><br>    Private Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.ItemCommand<br>        If e.CommandName = "ChangeFlag" Then<br><br>            Dim MyId As Integer = (DirectCast(e.Item, GridDataItem)).GetDataKeyValue("MessageId").ToString()<br>            <br>            MessagesClass.EditFlag(MyId)<br><br>            e.Item.OwnerTableView.Rebind()<br><br>        End If<br>    End Sub<br><br><br>    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)<br>        Select Case e.Argument.ToString()<br>            Case "ChangePageSize"<br>                'Calculate the number of rows that fit in the RadPane.<br>                'In this case 23 is the sum of the height of a single row and its upper border width.<br>                'Depending on the paticular scenario this value may vary.<br>                Dim rows As Integer = (Int32.Parse(Me.Rp1.Height.Value.ToString()) - 60) / 23<br>                If rows >= 1 Then<br>                    RadGrid1.PageSize = rows<br><br>                    ' Check whether the CurrentPageIndex is correct.<br>                    If Session("itemsCount") IsNot Nothing Then<br>                        Dim itemsCount As Integer = CInt(Session("itemsCount"))<br>                        Dim pageCount As Integer = CInt(Math.Ceiling((CDbl(itemsCount) / rows)))<br>                        If RadGrid1.MasterTableView.CurrentPageIndex > pageCount - 1 Then<br>                            RadGrid1.MasterTableView.CurrentPageIndex = pageCount - 1<br>                        End If<br>                    End If<br><br>                    RadGrid1.Rebind()<br>                End If<br>                Exit Select<br>        End Select<br>    End Sub<br><br>    Public RadGrid1PanelClientID As String<br><br>    Protected Sub RadAjaxManager1_AjaxSettingCreated(sender As Object, e As AjaxSettingCreatedEventArgs)<br>        If e.Initiator.ID = "RadGrid1" Then<br>            Me.RadGrid1PanelClientID = e.UpdatePanel.ClientID<br>        End If<br>    End Sub<br><br><br>    Protected Sub RadGrid1_DeleteCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.DeleteCommand<br>        Dim MessageId = TryCast(e.Item, GridDataItem).GetDataKeyValue("MessageId").ToString()<br>        MessagesClass.DeleteMessage(MessageId)<br>    End Sub<br><br>End Class

    Hope there will be a solution.

    Best regards,

    Herve
  5. Herve
    Herve avatar
    39 posts
    Member since:
    Jun 2008

    Posted 06 Oct 2013 Link to this post

    Hi again Princy,

    I have modified my code and found that the rebind of the datagrid at the bottom of SelectedIndexChanged was the problem.

    I'm rebinding the Datagrid because when an user click on a row, I want to mark it as read by modifying its style after having recorded this change in the DB. If I do not rebind, the change is visible at the full refresh of the page and not immediately like it is by rebinding.

    Is there in you opinion a work around allowing to fix it ?

    Thanks,


    Herve
  6. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Oct 2013 Link to this post

    Hi Herve,

    It's hard to get you code,please paste your code using Format Code Block .Below is a sample code that i tried to get the selected row and its datakey value.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnSelectedIndexChanged="RadGrid1_SelectedIndexChanged1">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" />
                <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" />
            </Columns>
        </MasterTableView>
        <ClientSettings EnablePostBackOnRowClick="true" Selecting-AllowRowSelect="true">
        </ClientSettings>
    </telerik:RadGrid>

    VB:
    Protected Sub RadGrid1_SelectedIndexChanged1(sender As Object, e As EventArgs)
        Dim selectedItem As GridDataItem = DirectCast(RadGrid1.SelectedItems(0), GridDataItem)
        'accessing selected row
        Dim value As String = selectedItem.GetDataKeyValue("OrderID").ToString()
        selectedItem.CssClass = "color"
    End Sub

    CSS:
    <style type="text/css">
     .color
     {
      background-color: Aqua !important;
     }
    </style>

    Thanks,
    Princy
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017