- Home
- Forum
- ASP.NET Web Forms
- Cant identify checked items
Cant identify checked items
Good evening.
We are working on an asp.net webforms application.
I am using ListView to display a list of records (bound to a List<>) and enabled the check boxes (EnableCheckMark) for selection. I am having 2 problems:
- If I set DataPrimaryKeyField with the record id field name, the list wont show the checkboxes.
- When doing postback I haven't found a way to get which elements are checked. How can I achive that?
I am using Visual Studio 2015, and the assembly version 15.4460.0.17
Let me know if you need more information.
Best regards,
Andrés
SIGN IN To post a reply.
3 Replies
AP
Arun Palaniyandi
Syncfusion Team
December 8, 2017 01:47 PM UTC
Hi Andres,
Thanks for using Syncfusion Products.
Query1:”If I set DataPrimaryKeyField with the record id field name, the list wont show the checkboxes.”
As per our Listview current implementation, if the PrimaryKeyField is set then it will be considered as parent nested Listview. Hence in this case if we enable checkbox property then this parent won’t show the checkboxes but for the child it will be rendered.
Demo Link: http://jsplayground.syncfusion.com/sxptv41d
Query2:”When doing postback I haven't found a way to get which elements are checked. How can I achive that?”
We achieve this requirement by using the getCheckedItems method. Through this method we can get the checked items and then can take the checked items id or text. Later we can use the simple AJAX post to send it to server side. Please find the below code snippets for more references.
|
<ej:ListView ID="ListView1" Height="450" Width="400" DataTextField="Text" EnableCheckMark="true" runat="server" >
</ej:ListView>
<ej:Button runat="server" ID="btn" Text="Save" ClientSideOnClick="onclick"></ej:Button>
<script type="text/javascript">
$(function () {
$("#MainContent_ListView1").ejListView({ fieldSettings: { id: "ID" } }) // include the field Id here
})
function onclick() {
Listobj = $("#MainContent_ListView1").ejListView("instance")
litem = Listobj.getCheckedItems(); // get the checked items
listdata = [];
for (var i = 0; i < litem.length; i++) {
listdata.push(litem[i].getAttribute("data-id")); //take the id/text here, use the data-id/data-text attribute
}
PageMethods.GetData(listdata.toString(), onSucess, onError); // send to server side
}
</script>
|
Please find the below sample for more reference.
If the provided information and sample does not meet your requirement or if we misunderstood your query, please get back to us with more information, so that it will help us to provide the solution at earliest.
Regards,
Arun P.
AN
Andres
March 6, 2018 06:20 PM UTC
Sorry about the late answer.
Thanks a lot by your help.
It worked like a charm.
Thanks a lot by your help.
AP
Arun Palaniyandi
Syncfusion Team
March 7, 2018 04:07 AM UTC
Hi Andres,
Thanks for your update.
We are glad that our solution has helped you out.
Please let us know if you have any queries in future.
Regards,
Arun P.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
AN Andres
- Dec 7, 2017 05:15 PM UTC
- Mar 7, 2018 04:07 AM UTC