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

SelectedIndexChanged in GridTableView

2 Answers 207 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anne
Top achievements
Rank 1
Anne asked on 22 Aug 2014, 04:10 AM
Hi,
I am working on a menu using a RadGrid. developing in C#

I have a MasterTableView that contains the Main information, and one GridTableView in DetailTables. (Check menu attach file)
Once I click the expanded icon on then master table, the grid table view is displayed.

I am looking at selecting a record on the GridTableView (by clicking on the record) to open a form.

However the OnSelectedIndexChanged is not firing.
So I don't know if it should be set up diferently when in a GridTableView (as it is working if I put the event in the RadGrid at a higher level)
Or if I should use another event.

This is how I have set it up (Check html file attached for more details):
- EnablePostBackOnRowClick="true" in the Client settings of the RadGrid.
- OnSelectedIndexChanged="GV_SelectedIndexChanged" set up in the GridTableView, and the C# code added accordingly.

Thank you for your help.

Anne

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 22 Aug 2014, 05:22 AM
Hi Anne,

If you want the OnSelectedIndexChanged event of the RadGrid you can set it up in the RadGrid itself and it will fire for all tables. In order for this event to fire set EnablePostBackOnRowClick="true"  and in code behind you can identify which table caused the postback as follows:

ASPX:
<telerik:RadGrid ID="rgrdSample" runat="server" OnSelectedIndexChanged="rgrdSample_SelectedIndexChanged">
    . . .
  <ClientSettings Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true">
  </ClientSettings>
</telerik:RadGrid>

C#:
protected void rgrdSample_SelectedIndexChanged(object sender, EventArgs e)
{
    foreach (GridDataItem selectedItem in rgrdSample.SelectedItems)
    {
       //Identify the Detail Tables using Name
        if (selectedItem.OwnerTableView.Name == "You GridTableView Name")
        {
            //Code
        }
    }
}

Thanks,
Shinu
0
Anne
Top achievements
Rank 1
answered on 25 Aug 2014, 12:08 PM
Thank you. It's working now. I think the SelectedIndexChanged event was not firing from the grid as I had one as well in the GridTable View.
All working now, thanks again
Tags
General Discussions
Asked by
Anne
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Anne
Top achievements
Rank 1
Share this question
or