- Home
- Forum
- ASP.NET Web Forms
- How to get all selected records in server-side code
How to get all selected records in server-side code
I have a Grid control with AllowSelection="true" and Selectiontype="Multiple" so that multiple rows can be selected.
In server side C# code, I can use the following code to get indices of all the selected rows in the current page.
List<int> indices = myEJGrid.SelectedRowIndices;
However, I couldn't find any methods to get the corresponding data records of these rows. Does anybody know how? Thanks.
SIGN IN To post a reply.
3 Replies
FS
Farveen Sulthana Thameeztheen Basha
Syncfusion Team
June 4, 2018 12:56 PM UTC
Hi Huifei,
Thanks for contacting Syncfusion Support.
We have checked your query and To achieve your requirement, we suggest to use the get the selected Records value from getSelectedRecords method on the RowSelected event of the Grid. After that you can assign the value to the hidden element and get the value in the OnserverRowSelect event or any other button click event.
Please refer to the code example:-
|
Aspx:-
<asp:HiddenField ID="SelectRecords" ClientIDMode="Static" runat="server" />
<ej:Grid ID="FlatGrid" runat="server" AllowPaging="True" IsResponsive="true" AllowScrolling="true" AllowFiltering="true" OnServerRowSelected="FlatGrid_OnServerRowSelected" AllowSelection="true" Selectiontype="Multiple" >
<Columns>
<ej:Column Field="OrderID" HeaderText="Order ID" IsPrimaryKey="True" TextAlign="Right" Width="80" />
. . .
</Columns>
<ClientSideEvents RowSelected="rowSelect" />
</ej:Grid>
<script type="text/javascript">
function rowSelect(args) {
var record = this.getSelectedRecords();
$("#SelectRecords").val(JSON.stringify(record));
}
</script>
Serverside:-
protected void FlatGrid_OnServerRowSelected(object sender, Syncfusion.JavaScript.Web.GridEventArgs e)
{
JavaScriptSerializer ser = new JavaScriptSerializer();
List<Orders> sel = ser.Deserialize <List<Orders>>(this.SelectRecords.Value);
}
|
Please refer to the API link:-
Please get back to us if you need any further assistance.
Regards,
Farveen sulthana T
HR
Huifei Rao
June 6, 2018 08:26 PM UTC
Thanks. It works.
FS
Farveen Sulthana Thameeztheen Basha
Syncfusion Team
June 7, 2018 04:03 AM UTC
Hi Huifei,
Thanks for your update. Please get back to us if you need any further asssitance.
Regards,
Farveen sulthana T
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
HR Huifei Rao
- Jun 1, 2018 08:16 PM UTC
- Jun 7, 2018 04:03 AM UTC