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

¿How server side and client side access to selected rows?

Thread ID:

Created:

Updated:

Platform:

Replies:

124387 Jun 6,2016 03:48 PM UTC Jun 7,2016 12:36 PM UTC ASP.NET Web Forms 2
loading
Tags: Grid
Daniel Cruzado Jimenez
Asked On June 6, 2016 03:48 PM UTC

On v14.1.0.46 , How could I server side (C#) and client side access to selected rows in the Grid?

Daniel Cruzado Jimenez
Replied On June 6, 2016 04:05 PM UTC

I means not Row Index. I means the Row object.

Prasanna Kumar Viswanathan [Syncfusion]
Replied On June 7, 2016 12:36 PM UTC

Hi Daniel, 

Thank you for using Syncfusion products. 

To get the values from the selected row in client-side, use recordClick event of the ejGrid. This event is triggered when the record is clicked. In this event, we can get the selected row data in the arguments.       
 
Find the code example and sample: 


// Client-Side 

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> 
        <ej:Grid ID="Grid" runat="server" AllowPaging="True" AllowSorting="true" OnServerRecordClick="Grid_ServerRecordClick"> 
           <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings> 
           <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings> 
            <ClientSideEvents RecordClick="recordclick" />  
            <Columns> 
--------------------------------------------------- 
            </Columns> 
        </ej:Grid> 
 
<script> 
    function recordclick(args) { 
        var rowdata = args.data; 
    } 
</script> 
</asp:Content> 



Help document to know more about recordClick event:   


You can also get all the selected row values using the getSelectedRecords method. For more information, refer to the below help document: 


To get selected rows data on server side, use server side event “OnServerRecordClick”. In recordclick event, you can get the selected row in the data property of GridEventArgs arguments  

Find the code example: 


<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> 
        <ej:Grid ID="Grid" runat="server" AllowPaging="True" AllowSorting="true" OnServerRecordClick="Grid_ServerRecordClick"> 
           <EditSettings AllowEditing="True" AllowAdding="True" AllowDeleting="True"></EditSettings> 
           <ToolbarSettings ShowToolbar="True" ToolbarItems="add,edit,delete,update,cancel"></ToolbarSettings> 
            <ClientSideEvents RecordClick="recordclick" /> 
            <Columns> 
                --------------------------------------- 
           </Columns> 
        </ej:Grid> 
</asp:Content> 
 
--------------------------------------------------- 
protected void Grid_ServerRecordClick(object sender, GridEventArgs e) 
        { 
            Orders value = new Orders(); 
            List<Orders> data = ViewState["DataSource"] as List<Orders>; 
            Dictionary<string, object> KeyVal = e.Arguments["data"] as Dictionary<string, object>; 
          
                foreach (KeyValuePair<string, object> keyval in KeyVal) 
                { 
                   if (keyval.Key == "OrderID")                
                        value.OrderID = Convert.ToInt32(keyval.Value); 
                    else if (keyval.Key == "CustomerID") 
                        value.CustomerID = Convert.ToString(keyval.Value); 
                    else if (keyval.Key == "EmployeeID") 
                        value.EmployeeID = Convert.ToInt32(keyval.Value); 
                    else if (keyval.Key == "Freight") 
                        value.Freight = Convert.ToDouble(keyval.Value); 
                    else if (keyval.Key == "ShipCity") 
                        value.ShipCity = Convert.ToString(keyval.Value); 
                   } 
               } 
 
        } 

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

;