We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to get selected rows data in code behind?

Platform: ASP.NET Web Forms |
Control: Grid
Tags: selection

This explains the way of how to get the selected records data in the server side



       To get the selected row index in server side (code behind) use SelectedRowIndex API and using the index get the selected row data from the dataSource based on the current page.






Here we can get the selected records in grid based on the pageSize and current page.




Figure 1: shows the record has selected on page 3.




Figure 2: shows the selected row data in code behind.

2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
You must log in to leave a comment
Jul 24, 2018

This does work 100% if there is no filter on the original Grid.

How will it be done if there is a filter applied?

Kuralarasan Muthusamy [Syncfusion]
Jul 25, 2018

Hi Hercules,


From your given query, we found that you want to get the selected records in server side after the grid filtering. In this kb we have displayed the selected records from the grid dataSource by using selectedrowIndex. But in your cause, we suggest you to use filtered records instead of this grid dataSource to get the selected record. Because after the grid filtering selected row index was changed based on filtered records position. So you need to use this filtered records instead of the dataSource to get the selected records. We used DataOperations to get the filtered records in server side. You need to pass the grid dataSource and grid model to the dataOperations execute method to get the filtered records. Please refer the following code snippet;


        protected void button_Click(object sender, EventArgs e)


            var index = this.OrdersGrid.SelectedRowIndex;    //get the index of the selected row in current

            DataOperations ds = new DataOperations();

            var data1 = ds.Execute(order, this.OrdersGrid.Model); // passed the grid dataSource and grid dataSource in DataOperations execute method

            if (this.OrdersGrid.PageSettings.CurrentPage > 1)

                index = this.OrdersGrid.PageSettings.PageSize * (this.OrdersGrid.PageSettings.CurrentPage - 1) + index;

            var selectedRecord = data1.Cast<Orders>().ToList()[index]; // get the selected records from the filtered records


In this code we have used the filtered records to get the selected record in server side.


Also we have attached our sample for your reference and that sample can be downloadable from the below link,


Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/sample1197375515.zip



Kuralarasan M.


Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile