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

Grid SelectedRow / Data Server Side



Page with a Grid on it.
Separate ASP server side Button.

How do I get the selected rows data from within the server side event (Button Click)?
(SelectedRow Index is already available, but I don't know how to access this data).

Eg. Click on third row in grid, click asp button. Then server gets selected row AND extract data columns from selected row.

Or, must we use a client side script to post the data ourselves?

Thanks in advance

3 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team April 12, 2017 06:45 AM UTC

Hi Danie, 

Thanks for contacting Syncfusion support.  

To get the selected rows data in server-side event(Button Click), we use SelectedRowIndex. In server-side button click we get selected row index from the SelectedRowIndex API and using the index we get the selected row data from the dataSource.  

Find the code example and sample:  

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">   
<asp:Button ID="button" runat="server" Text="SelectedRow" OnClick="button_Click" /> 
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
         <ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" AllowPaging="True"> 

protected void Page_Load(object sender, EventArgs e) 
            ViewState["DataSource"] = order; 

protected void button_Click(object sender, EventArgs e) 
            var index = this.FlatGrid.SelectedRowIndex; 
            List<Orders> data = ViewState["DataSource"] as List<Orders>; 
            if(this.FlatGrid.PageSettings.CurrentPage > 1) 
               index = this.FlatGrid.PageSettings.PageSize * (this.FlatGrid.PageSettings.CurrentPage - 1) + index; 
            var selectedData = data[index]; 

Prasanna Kumar N.S.V 

DV Danie van Eeden April 12, 2017 08:54 AM UTC

Thank you very much.
I will try this and get back to you if I have any issues.

PK Prasanna Kumar Viswanathan Syncfusion Team April 13, 2017 03:59 AM UTC

Hi Danie, 

We will wait to hear from you. 

Prasanna Kumar N.S.V 

Live Chat Icon For mobile
Up arrow icon