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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid SelectedRow / Data Server Side

Thread ID:

Created:

Updated:

Platform:

Replies:

129951 Apr 11,2017 03:21 PM UTC Apr 13,2017 03:59 AM UTC ASP.NET Web Forms 3
loading
Tags: Grid
Danie van Eeden
Asked On April 11, 2017 03:21 PM UTC

Hi,

situation:

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

Prasanna Kumar Viswanathan [Syncfusion]
Replied On 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" /> 
    <div> 
         <ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" AllowPaging="True"> 
            <Columns> 
                ------------------------------------ 
           </Columns> 
        </ej:Grid> 
    </div> 
</asp:Content> 
 
---------------------------------------------- 

protected void Page_Load(object sender, EventArgs e) 
        { 
            BindDataSource(); 
            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]; 
        } 


Regards, 
Prasanna Kumar N.S.V 


Danie van Eeden
Replied On 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.


Prasanna Kumar Viswanathan [Syncfusion]
Replied On April 13, 2017 03:59 AM UTC

Hi Danie, 

We will wait to hear from you. 

Regards, 
Prasanna Kumar N.S.V 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;