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

Value is " " on event SelectedIndexChanged

1 Answer 106 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Denis asked on 30 Nov 2015, 02:31 PM

I tried to get the ID value from selected row in a RadGrid. But what I try, I keep the value " ".
The data is collected by a WCF webservice by the way.

Below the ASP code I use:

<telerik:RadScriptManager ID="RadScriptManager" runat="server" EnableHandlerDetection="false">
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <telerik:AjaxSetting AjaxControlID="gridSimCards">
                    <telerik:AjaxUpdatedControl ControlID="gridSimCards" />
    <div class="pagetitle"><asp:Literal ID="ltrPageTitle" runat="server" /></div>
    <telerik:RadGrid ID="gridSimCards" runat="server" EnableViewState="true" AutoGenerateColumns="false" Skin="Silk" AllowFilteringByColumn="true" AllowPaging="true" PageSize="10" AllowSorting="true"
        <ClientSettings EnablePostBackOnRowClick="true" EnableRowHoverStyle="true" AllowColumnsReorder="true">
            <Selecting AllowRowSelect="true" />
            <Resizing AllowColumnResize="true" ShowRowIndicatorColumn="true" />
            <DataBinding SelectMethod="GetSimCards"
                SortParameterName="sorter" SortParameterType="List"
                FilterParameterName="filter" FilterParameterType="List"  />
        <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />
        <MasterTableView Width="100%" DataKeyNames="ID">
                <telerik:GridBoundColumn UniqueName="ID" DataField="ID" HeaderText="#" DataType="System.String"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Provider" HeaderText="Provider" DataType="System.String"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Country" HeaderText="Land" DataType="System.String"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="SIMNumber" HeaderText="SIM-nummer" DataType="System.String"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="TelephoneNumber" HeaderText="Telefoonnummer" DataType="System.String"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ContactPeriodFrom" HeaderText="Contract van" DataType="System.DateTime"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ContractPeriodTill" HeaderText="Contract tot" DataType="System.DateTime"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="InUse" HeaderText="In gebruik" DataType="System.Boolean"></telerik:GridBoundColumn>


The code below is use to get the value of the selected ID column:

protected void gridSimCards_SelectedIndexChanged(object sender, EventArgs e)
    int selectedRowIdx = gridSimCards.SelectedItems[0].ItemIndex;
    GridDataItem selectedItem = (GridDataItem)gridSimCards.MasterTableView.Items[selectedRowIdx];
    string str = selectedItem["ID"].Text;


What am I doing wrong, or what am I missing?

1 Answer, 1 is accepted

Sort by
Konstantin Dikov
Telerik team
answered on 02 Dec 2015, 06:48 AM
Hello Denis,

Here is the answer from the support ticket that you have opened with the same question:

"With client-side binding, the values of the items will be available only on the client-side and it is not possible to retrieve them on a server-side event. With that in mind, if you need to retrieve the values from the selected item you will have to disable the "PostBackOnRowClick", which is initiating the postback, and handle the client-side OnRowSelecting or OnRowSelected events and retrieve the values there:

Best Regards,
Konstantin Dikov
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question