Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
I want to create a functionality in my Asp.net MVC website that enables users to tick a checkbox on the index page where records are listed and it redirects them to a page, where they can type in a surname in one text box and when they click on the submit button, all selected records are updated with that same surname.

I haven't got a clue as to how this can be implemented. I would really appreciate it if someone could give me a few pointers.



Thanks :)

What I have tried:

I have implemented the checkbox on the view, but I don't know how to get multiple ids from the checkboxes and to use them in another view
Posted
Comments
F-ES Sitecore 15-Sep-20 5:31am    
ids aren't submitted as part of the form. One way of doing this is to make sure the checkboxes all have the same "name" and the "value" of the checkbox will be the id of the record it represents. When you submit the form the value of the checkbox field will be all the ids comma separated, so "1,2,3,4". Store these values in the Session so you can recall them on your update page. If you can't get model binding to convert the comma list to an array of ids automatically you can do it yourself with the string.Split function. For each id execute an update statement, or you can keep the ids comma separated and use the "IN" SQL clause to batch update them;

update [table] set [surname] = 'name' where ID in (1,2,3,4)
[no name] 15-Sep-20 10:07am    
It's up to you; i.e. you write code. You have the selections and the name; you write the update query using the (database) keys of the selections.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900